Series.add

Return Addition of series and other, element-wise (binary operator add).

danfo.Series.add(other, options)

ParametersTypeDescriptionDefault

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

const dfd = require("danfojs-node")

let data1 = [30, 40, 3, 5]
let data2 = [1, 2, 3, 4]
let sf1 = new dfd.Series(data1)
let sf2 = new dfd.Series(data2)
sf1.add(sf2).print()
╔═══╤══════════════════════╗
║   │ 0                    ║
╟───┼──────────────────────╢
║ 0 │ 31                   ║
╟───┼──────────────────────╢
║ 1 │ 42                   ║
╟───┼──────────────────────╢
║ 2 │ 6                    ║
╟───┼──────────────────────╢
║ 3 │ 9                    ║
╚═══╧══════════════════════╝

subtract from a value

const dfd = require("danfojs-node")

let data1 = [1, 2, 3, 4, 5]
let sf1 = new dfd.Series(data1)

sf1.add(2).print()
╔═══╤══════════════════════╗
║   │ 0                    ║
╟───┼──────────────────────╢
║ 0 │ 3                    ║
╟───┼──────────────────────╢
║ 1 │ 4                    ║
╟───┼──────────────────────╢
║ 2 │ 5                    ║
╟───┼──────────────────────╢
║ 3 │ 6                    ║
╟───┼──────────────────────╢
║ 4 │ 7                    ║
╚═══╧══════════════════════╝

Last updated