description |
---|
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
{% tabs %} {% tab title="Node" %}
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()
{% endtab %}
{% tab title="Browser" %}
{% endtab %} {% endtabs %}
{% tabs %} {% tab title="Output" %}
╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗
║ │ 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 ║
╚═══╧════════════════════╝
{% endtab %} {% endtabs %}
{% tabs %} {% tab title="Node" %}
const dfd = require("danfojs-node")
let data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]]
let cols = ["A", "B", "C"]
let df = new dfd.DataFrame(data)
df.print()
df.mean({ axis: 0 }).print()
{% endtab %}
{% tab title="Browser" %}
{% endtab %} {% endtabs %}
{% tabs %} {% tab title="Output" %}
╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗
║ │ A │ B │ C ║
╟────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 0 │ 11 │ 20 │ 3 ║
╟────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 1 │ 1 │ 15 │ 6 ║
╟────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 2 │ 2 │ 30 │ 40 ║
╟────────────┼───────────────────┼───────────────────┼───────────────────╢
║ 3 │ 2 │ 89 │ 78 ║
╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝
╔═══╤═══════╗
║ A │ 4 ║
╟───┼───────╢
║ B │ 38.5 ║
╟───┼───────╢
║ C │ 31.75 ║
╚═══╧═══════╝
{% endtab %} {% endtabs %}