Danfo.js
Getting Started
API Reference
Contributing Guide
Github
Search…
Danfo.js Documentation
Getting Started
API reference
General Functions
Input/Output
Series
Dataframe
Creating a DataFrame
DataFrame.sortIndex
DataFrame.append
DataFrame.nUnique
DataFrame.tensor
DataFrame.print
DataFrame.toCSV
DataFrame.toJSON
DataFrame.toExcel
DataFrame.sortValues
DataFrame.setIndex
DataFrame.resetIndex
DataFrame.rename
DataFrame.drop
DataFrame.asType
DataFrame.shape
DataFrame.axis
DataFrame.ndim
DataFrame.values
DataFrame.selectDtypes
DataFrame.ctypes
DataFrame.index
DataFrame.loc
DataFrame.iloc
DataFrame.at
DataFrame.iat
DataFrame.head
DataFrame.tail
DataFrame.sample
DataFrame.add
DataFrame.sub
DataFrame.mul
DataFrame.div
DataFrame.pow
DataFrame.mod
DataFrame.mean
DataFrame.median
DataFrame.min
DataFrame.max
DataFrame.std
DataFrame.var
DataFrame.count
DataFrame.round
DataFrame.cumSum
DataFrame.cumMin
DataFrame.cumMax
DataFrame.cumProd
DataFrame.copy
DataFrame.describe
DataFrame.sum
DataFrame.abs
DataFrame.query
DataFrame.addColumn
DataFrame.groupby
DataFrame.column
DataFrame.fillNa
DataFrame.isNa
DataFrame.dropNa
DataFrame.apply
DataFrame.applyMap
DataFrame.It
DataFrame.gt
DataFrame.le
DataFrame.ge
DataFrame.ne
DataFrame.eq
DataFrame.replace
Configuration Options
Plotting
Groupby
User Guides
Building Data Driven Applications with Danfo.js - Book
Contributing Guide
Release Notes
Powered By
GitBook
DataFrame.mod
Get Modulo of DataFrame and other, element-wise (binary operator mod).
danfo.DataFrame.mod(other, option)
Parameters
Type
Description
Default
other
DataFrame, Series, Array or Scalar
Object to modulo with
option
Object
{
axis
: 0 for row, 1 for column.
inplace
: Boolean indicating whether to perform the operation inplace or not. Defaults to false
}
{ axis: 1, inplace: false }
Examples
Modulo of
scalar with
DataFrame along default axis 1
Node
Browser
1
const
dfd
=
require
(
"danfojs-node"
)
2
3
let
data
=
{
4
"Col1"
:
[
10
,
45
,
56
,
10
],
5
"Col2"
:
[
23
,
20
,
10
,
24
]
6
}
7
let
df
=
new
dfd
.
DataFrame
(
data
)
8
9
let
df_new
=
df
.
mod
(
2
)
10
11
df_new
.
print
()
Copied!
1
Copied!
Output
1
╔════════════╤═══════════════════╤═══════════════════╗
2
║ │ Col1 │ Col2 ║
3
╟────────────┼───────────────────┼───────────────────╢
4
║ 0 │ 0 │ 1 ║
5
╟────────────┼───────────────────┼───────────────────╢
6
║ 1 │ 1 │ 0 ║
7
╟────────────┼───────────────────┼───────────────────╢
8
║ 2 │ 0 │ 0 ║
9
╟────────────┼───────────────────┼───────────────────╢
10
║ 3 │ 0 │ 0 ║
11
╚════════════╧═══════════════════╧═══════════════════╝
12
Copied!
Modulo of
Series with
DataFrame along axis 0
Node
Browser
1
const
dfd
=
require
(
"danfojs-node"
)
2
3
let
data
=
{
4
"Col1"
:
[
1
,
4
,
5
,
1
],
5
"Col2"
:
[
3
,
2
,
0
,
4
]
6
}
7
8
let
df
=
new
dfd
.
DataFrame
(
data
)
9
let
sf
=
new
dfd
.
Series
([
4
,
5
])
10
11
let
df_new
=
df
.
mod
(
sf
,
{
axis
:
1
})
12
13
df_new
.
print
()
Copied!
1
Copied!
Output
1
╔════════════╤═══════════════════╤═══════════════════╗
2
║ │ Col1 │ Col2 ║
3
╟────────────┼───────────────────┼───────────────────╢
4
║ 0 │ 1 │ 3 ║
5
╟────────────┼───────────────────┼───────────────────╢
6
║ 1 │ 0 │ 2 ║
7
╟────────────┼───────────────────┼───────────────────╢
8
║ 2 │ 1 │ 0 ║
9
╟────────────┼───────────────────┼───────────────────╢
10
║ 3 │ 1 │ 4 ║
11
╚════════════╧═══════════════════╧═══════════════════╝
12
Copied!
Modulo of DataFrame with a DataFrame
Node
Browser
1
const
dfd
=
require
(
"danfojs"
)
2
3
let
data
=
{
"Col1"
:
[
1
,
4
,
5
,
0
],
4
"Col2"
:
[
2
,
0
,
1
,
4
]}
5
6
let
data2
=
{
"new_col1"
:
[
1
,
5
,
20
,
10
],
7
"new_Col2"
:
[
20
,
2
,
1
,
2
]}
8
9
let
df
=
new
dfd
.
DataFrame
(
data
)
10
let
df2
=
new
dfd
.
DataFrame
(
data2
)
11
12
let
df_new
=
df
.
mod
(
df2
)
13
14
df_new
.
print
()
Copied!
1
Copied!
Output
1
╔════════════╤═══════════════════╤═══════════════════╗
2
║ │ Col1 │ Col2 ║
3
╟────────────┼───────────────────┼───────────────────╢
4
║ 0 │ 0 │ 2 ║
5
╟────────────┼───────────────────┼───────────────────╢
6
║ 1 │ 4 │ 0 ║
7
╟────────────┼───────────────────┼───────────────────╢
8
║ 2 │ 5 │ 0 ║
9
╟────────────┼───────────────────┼───────────────────╢
10
║ 3 │ 0 │ 0 ║
11
╚════════════╧═══════════════════╧═══════════════════╝
12
Copied!
Modulo of Array with DataFrame along axis 0
Node
Browser
1
const
dfd
=
require
(
"danfojs-node"
)
2
3
let
data
=
{
4
"Col1"
:
[
10
,
45
,
56
,
10
],
5
"Col2"
:
[
23
,
20
,
10
,
24
]
6
}
7
8
let
df
=
new
dfd
.
DataFrame
(
data
)
9
let
val
=
[
2
,
2
,
2
,
2
]
10
11
let
df_new
=
df
.
mod
(
val
,
{
axis
:
0
})
12
13
df_new
.
print
()
Copied!
1
Copied!
Output
1
╔════════════╤═══════════════════╤═══════════════════╗
2
║ │ Col1 │ Col2 ║
3
╟────────────┼───────────────────┼───────────────────╢
4
║ 0 │ 0 │ 1 ║
5
╟────────────┼───────────────────┼───────────────────╢
6
║ 1 │ 1 │ 0 ║
7
╟────────────┼───────────────────┼───────────────────╢
8
║ 2 │ 0 │ 0 ║
9
╟────────────┼───────────────────┼───────────────────╢
10
║ 3 │ 0 │ 0 ║
11
╚════════════╧═══════════════════╧═══════════════════╝
Copied!
Modulo works inplace
Node
Browser
1
const
dfd
=
require
(
"danfojs-node"
)
2
3
let
data
=
{
4
"Col1"
:
[
10
,
45
,
56
,
10
],
5
"Col2"
:
[
23
,
20
,
10
,
24
]
6
}
7
8
let
df
=
new
dfd
.
DataFrame
(
data
)
9
let
val
=
[
2
,
2
,
2
,
2
]
10
11
df
.
mod
(
val
,
{
axis
:
0
,
inplace
:
true
})
12
13
df
.
print
()
Copied!
1
Copied!
Output
1
╔════════════╤═══════════════════╤═══════════════════╗
2
║ │ Col1 │ Col2 ║
3
╟────────────┼───────────────────┼───────────────────╢
4
║ 0 │ 0 │ 1 ║
5
╟────────────┼───────────────────┼───────────────────╢
6
║ 1 │ 1 │ 0 ║
7
╟────────────┼───────────────────┼───────────────────╢
8
║ 2 │ 0 │ 0 ║
9
╟────────────┼───────────────────┼───────────────────╢
10
║ 3 │ 0 │ 0 ║
11
╚════════════╧═══════════════════╧═══════════════════╝
12
Copied!
Previous
DataFrame.pow
Next
DataFrame.mean
Last modified
3mo ago
Copy link
Contents
Examples
Modulo of scalar with DataFrame along default axis 1
Modulo of Series with DataFrame along axis 0
Modulo of DataFrame with a DataFrame
Modulo of Array with DataFrame along axis 0
Modulo works inplace