Powered By GitBook
Series.add
Return Addition of series and other, element-wise (binary operator add).
danfo.Series.add(other, options) [source]
Parameters
Type
Description
Default
other
Series|int|
values
options
Object
inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false
{
inplace: false
}
Return: Series
Example
subtract from values of another series
Node
1
const dfd = require("danfojs-node")
2
3
let data1 = [30, 40, 3, 5]
4
let data2 = [1, 2, 3, 4]
5
let sf1 = new dfd.Series(data1)
6
let sf2 = new dfd.Series(data2)
7
sf1.add(sf2).print()
Copied!
Output
1
╔═══╤══════════════════════╗
2
║ │ 0 ║
3
╟───┼──────────────────────╢
4
║ 0 │ 31 ║
5
╟───┼──────────────────────╢
6
║ 1 │ 42 ║
7
╟───┼──────────────────────╢
8
║ 2 │ 6 ║
9
╟───┼──────────────────────╢
10
║ 3 │ 9 ║
11
╚═══╧══════════════════════╝
Copied!
subtract from 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.add(2).print()
Copied!
Output
1
╔═══╤══════════════════════╗
2
║ │ 0 ║
3
╟───┼──────────────────────╢
4
║ 0 │ 3 ║
5
╟───┼──────────────────────╢
6
║ 1 │ 4 ║
7
╟───┼──────────────────────╢
8
║ 2 │ 5 ║
9
╟───┼──────────────────────╢
10
║ 3 │ 6 ║
11
╟───┼──────────────────────╢
12
║ 4 │ 7 ║
13
╚═══╧══════════════════════╝
Copied!
Last modified 13d ago
Copy link