DataFrame.count

Count non-NaN cells for each column or row. The values NaN and undefined are considered NaN

danfo.DataFrame.count(options)

Examples

Count Non-NaN values along default axis 1 (column)

const dfd = require("danfojs-node")

let data = { "Name": ["Apples", "Mango", "Banana", undefined],
           "Count": [NaN, 5, NaN, 10],
           "Price": [200, 300, 40, 250] }

let df = new dfd.DataFrame(data)
df.count().print()
╔═══╤═══╗
║ 0 │ 2 ║
╟───┼───╢
║ 1 │ 3 ║
╟───┼───╢
║ 2 │ 2 ║
╟───┼───╢
║ 3 │ 2 ║
╚═══╧═══╝

Count Non-NaN values along row axis (0)

const dfd = require("danfojs-node")

let data = { "Name": ["Apples", "Mango", "Banana", undefined],
           "Count": [NaN, 5, NaN, 10],
           "Price": [200, 300, 40, 250] }

let df = new dfd.DataFrame(data)
df.count({axis: 0}).print()
╔═══════╤═══╗
║ Name  │ 3 ║
╟───────┼───╢
║ Count │ 2 ║
╟───────┼───╢
║ Price │ 4 ║
╚═══════╧═══╝

Last updated