danfo.DataFrame.mean(axis) [source]
Parameters | Type | Description | Default |
axis | Int | 0 for row and 1 for columns | 1 |
Returns:
return Series
const dfd = require("danfojs-node")data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]]cols = ["A", "B", "C"]df.print()let df = new dfd.DataFrame(data)df.mean().print()
╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗║ │ A │ B │ C ║╟───┼───────────────────┼───────────────────┼───────────────────╢║ 0 │ 11 │ 20 │ 3 ║╟───┼───────────────────┼───────────────────┼───────────────────╢║ 1 │ 1 │ 15 │ 6 ║╟───┼───────────────────┼───────────────────┼───────────────────╢║ 2 │ 2 │ 30 │ 40 ║╟───┼───────────────────┼───────────────────┼───────────────────╢║ 3 │ 2 │ 89 │ 78 ║╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝╔═══╤══════════════════════╗║ │ 0 ║╟───┼──────────────────────╢║ A │ 4 ║╟───┼──────────────────────╢║ B │ 38.5 ║╟───┼──────────────────────╢║ C │ 31.75 ║╚═══╧══════════════════════╝
const dfd = require("danfojs-node")data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]]cols = ["A", "B", "C"]df.print()let df = new dfd.DataFrame(data)df.mean(axis=0).print()
╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗║ │ A │ B │ C ║╟───┼───────────────────┼───────────────────┼───────────────────╢║ 0 │ 11 │ 20 │ 3 ║╟───┼───────────────────┼───────────────────┼───────────────────╢║ 1 │ 1 │ 15 │ 6 ║╟───┼───────────────────┼───────────────────┼───────────────────╢║ 2 │ 2 │ 30 │ 40 ║╟───┼───────────────────┼───────────────────┼───────────────────╢║ 3 │ 2 │ 89 │ 78 ║╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝╔═══╤══════════════════════╗║ │ 0 ║╟───┼──────────────────────╢║ 0 │ 11.333333015441895 ║╟───┼──────────────────────╢║ 1 │ 7.333333492279053 ║╟───┼──────────────────────╢║ 2 │ 24 ║╟───┼──────────────────────╢║ 3 │ 56.33333206176758 ║╚═══╧══════════════════════╝