DataFrame.add

Get Addition of DataFrame and other, element-wise (binary operator add).

danfo.DataFrame.add(other, option)

Parameters
Type
Description
Default

other

DataFrame, Series, Array or Scalar

Object to add 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

Addition of scalar to DataFrame along default axis 1

const dfd = require("danfojs-node")

let data = {
    "Col1": [10, 45, 56, 10],
    "Col2": [23, 20, 10, 24]
}
let df = new dfd.DataFrame(data)

let df_new = df.add(2)

df_new.print()
╔═══╤═══════════════════╤═══════════════════╗
║   │ Col1              │ Col2              ║
╟───┼───────────────────┼───────────────────╢
║ 0 │ 12                │ 25                ║
╟───┼───────────────────┼───────────────────╢
║ 1 │ 47                │ 22                ║
╟───┼───────────────────┼───────────────────╢
║ 2 │ 58                │ 12                ║
╟───┼───────────────────┼───────────────────╢
║ 3 │ 12                │ 26                ║
╚═══╧═══════════════════╧═══════════════════╝

Addition of Series to DataFrame along axis 0

Addition of DataFrame to a DataFrame

Addition of Array to DataFrame along axis 0

Addition works inplace

Last updated

Was this helpful?