Series.mod
Returns Modulo of series and other, element-wise (binary operator mod).
danfo.Series.mod(other, options)
Parameters
Type
Description
Default
other
Series|int|float
values
options
Object
inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false
{
inplace: false
}
Return: Series
Example
Modulus with values of another series
Node
1
const dfd = require("danfojs-node")
2
3
let data1 = [2, 30, 4, 5]
4
let data2 = [1.1, 2.2, 3.3, 2.4]
5
let sf1 = new dfd.Series(data1)
6
let sf2 = new dfd.Series(data2)
7
sf1.mod(sf2).print()
Copied!
Output
1
╔═══╤═════════════════════╗
2
║ 0 │ 0.8999999999999999 ║
3
╟───┼─────────────────────╢
4
║ 1 │ 1.3999999999999977 ║
5
╟───┼─────────────────────╢
6
║ 2 │ 0.7000000000000002 ║
7
╟───┼─────────────────────╢
8
║ 3 │ 0.20000000000000018 ║
9
╚═══╧═════════════════════╝
Copied!
Modulo with a value
Node
1
const dfd = require("danfojs-node")
2
3
let data1 = [1, 2, 3, 4, 5]
4
let sf1 = new dfd.Series(data1)
5
6
sf1.mod(2).print()
Copied!
Output
1
╔═══╤═══╗
2
║ 0 │ 1 ║
3
╟───┼───╢
4
║ 1 │ 0 ║
5
╟───┼───╢
6
║ 2 │ 1 ║
7
╟───┼───╢
8
║ 3 │ 0 ║
9
╟───┼───╢
10
║ 4 │ 1 ║
11
╚═══╧═══╝
Copied!
Copy link