Powered By GitBook
Series.sub
Return Subtraction of series and other, element-wise (binary operator sub).
danfo.Series.sub(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.sub(sf2).print()
Copied!
Output
1
╔═══╤══════════════════════╗
2
║ │ 0 ║
3
╟───┼──────────────────────╢
4
║ 0 │ 29 ║
5
╟───┼──────────────────────╢
6
║ 1 │ 38 ║
7
╟───┼──────────────────────╢
8
║ 2 │ 0 ║
9
╟───┼──────────────────────╢
10
║ 3 │ 1 ║
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.sub(2).print()
Copied!
Output
1
╔═══╤══════════════════════╗
2
║ │ 0 ║
3
╟───┼──────────────────────╢
4
║ 0 │ -1 ║
5
╟───┼──────────────────────╢
6
║ 1 │ 0 ║
7
╟───┼──────────────────────╢
8
║ 2 │ 1 ║
9
╟───┼──────────────────────╢
10
║ 3 │ 2 ║
11
╟───┼──────────────────────╢
12
║ 4 │ 3 ║
13
╚═══╧══════════════════════╝
Copied!
Last modified 24d ago
Copy link