For the complete documentation index, see llms.txt. This page is also available as Markdown.

DataFrame.mean

Returns the mean of the values for the requested axis.

danfo.DataFrame.mean(options)

Parameters
Type
Description
Default

options

Object

axis: 0 or 1. If 0, compute the mean column-wise, if 1, row-wise. Defaults to 1

{ axis: 1 }

Returns:

**** return Series

Examples

Computes the mean of values along default axis 1 (column)

const dfd = require("danfojs-node")

data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]]
cols = ["A", "B", "C"]

let df = new dfd.DataFrame(data)
df.print()
df.mean().print()
╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗
║   │ A                 │ B                 │ C                 ║
╟───┼───────────────────┼───────────────────┼───────────────────╢
║ 0 │ 11                │ 20                │ 3                 ║
╟───┼───────────────────┼───────────────────┼───────────────────╢
║ 1 │ 1                 │ 15                │ 6                 ║
╟───┼───────────────────┼───────────────────┼───────────────────╢
║ 2 │ 2                 │ 30                │ 40                ║
╟───┼───────────────────┼───────────────────┼───────────────────╢
║ 3 │ 2                 │ 89                │ 78                ║
╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝

╔═══╤════════════════════╗
║ 0 │ 11.333333333333334 ║
╟───┼────────────────────╢
║ 1 │ 7.333333333333333  ║
╟───┼────────────────────╢
║ 2 │ 24                 ║
╟───┼────────────────────╢
║ 3 │ 56.333333333333336 ║
╚═══╧════════════════════╝

Computes the mean of values along row axis (0)

Last updated