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

DataFrame.median

Return the median of the values for the requested axis.

danfo.DataFrame.median(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 }

Examples

Computes the median 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.median().print()
╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗
║            │ A                 │ B                 │ C                 ║
╟────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 0          │ 11                │ 20                │ 3                 ║
╟────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 1          │ 1                 │ 15                │ 6                 ║
╟────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 2          │ 2                 │ 30                │ 40                ║
╟────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 3          │ 2                 │ 89                │ 78                ║
╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝

╔═══╤════╗
║ 0 │ 11 ║
╟───┼────╢
║ 1 │ 6  ║
╟───┼────╢
║ 2 │ 30 ║
╟───┼────╢
║ 3 │ 78 ║
╚═══╧════╝

Computes the median of values along row axis (0)

Last updated