MCPcopy Index your code
hub / github.com/javascriptdata/danfojs / var

Method var

src/danfojs-base/core/frame.ts:1055–1074  ·  view source on GitHub ↗

* Return variance of values in a DataFrame across specified axis. * @param options.axis 0 or 1. If 0, compute the variance column-wise, if 1, add row-wise. Defaults to 1 * @example * ``` * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']}) * df.var().print()

(options?: { axis?: 0 | 1 })

Source from the content-addressed store, hash-verified

1053 * ```
1054 */
1055 var(options?: { axis?: 0 | 1 }): Series {
1056 const { axis } = { axis: 1, ...options }
1057
1058 if (this.$frameIsNotCompactibleForArithmeticOperation()) {
1059 throw Error("TypeError: var operation is not supported for string dtypes");
1060 }
1061
1062 if ([0, 1].indexOf(axis) === -1) {
1063 throw Error("ParamError: Axis must be 0 or 1");
1064 }
1065
1066 const newData = this.$getDataByAxisWithMissingValuesRemoved(axis)
1067 const resultArr = newData.map(arr => variance(arr))
1068 if (axis === 0) {
1069 return new Series(resultArr, { index: this.columns });
1070 } else {
1071 return new Series(resultArr, { index: this.index });
1072 }
1073
1074 }
1075
1076 /**
1077 * Get Less than of dataframe and other, element-wise (binary operator lt).

Callers

nothing calls this directly

Calls 4

indexOfMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected