DataFrame.count

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

danfo.DataFrame.count(axis) [source]

Parameters

Type

Description

Default

axis

Int

0 for row and 1 for columns

1

Returns:

return Series

Examples

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

Node
Browser
Node
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()
Browser
Output
Output
╔═══════╤══════════════════════╗
║ │ 0 ║
╟───────┼──────────────────────╢
║ Name │ 3 ║
╟───────┼──────────────────────╢
║ Count │ 2 ║
╟───────┼──────────────────────╢
║ Price │ 4 ║
╚═══════╧══════════════════════╝

Count Non-NaN values along row axis (0)

Node
Browser
Node
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()
Browser
Output
Output
╔═══╤══════════════════════╗
║ │ 0 ║
╟───┼──────────────────────╢
║ 0 │ 2 ║
╟───┼──────────────────────╢
║ 1 │ 3 ║
╟───┼──────────────────────╢
║ 2 │ 2 ║
╟───┼──────────────────────╢
║ 3 │ 2 ║
╚═══╧══════════════════════╝