DataFrame.div

Get division of DataFrame and other, element-wise

danfo.DataFrame.div(other, option)

Parameters
Type
Description
Default

other

DataFrame, Series, Array or Scalar

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

Division of scalar with 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.div(2)

df_new.print()
╔════════════╤═══════════════════╤═══════════════════╗
║            │ Col1              │ Col2              ║
╟────────────┼───────────────────┼───────────────────╢
║ 0          │ 5                 │ 11.5              ║
╟────────────┼───────────────────┼───────────────────╢
║ 1          │ 22.5              │ 10                ║
╟────────────┼───────────────────┼───────────────────╢
║ 2          │ 28                │ 5                 ║
╟────────────┼───────────────────┼───────────────────╢
║ 3          │ 5                 │ 12                ║
╚════════════╧═══════════════════╧═══════════════════╝

Division of Series with DataFrame along axis 0

Division of DataFrame with another DataFrame

Division of Array with DataFrame along axis 0

Division works inplace

Last updated