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

Method count

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

* Return number of non-null elements in a Series * @param options.axis 0 or 1. If 0, count column-wise, if 1, add row-wise. Defaults to 1 * @example * ``` * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']}) * df.count().print() * ``` * * @exa

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

Source from the content-addressed store, hash-verified

1305 * ```
1306 */
1307 count(options?: { axis?: 0 | 1 }): Series {
1308 const { axis } = { axis: 1, ...options }
1309
1310 if ([0, 1].indexOf(axis) === -1) {
1311 throw Error("ParamError: Axis must be 0 or 1");
1312 }
1313
1314 const newData = this.$getDataByAxisWithMissingValuesRemoved(axis)
1315 const resultArr = newData.map(arr => arr.length)
1316 if (axis === 0) {
1317 return new Series(resultArr, { index: this.columns });
1318 } else {
1319 return new Series(resultArr, { index: this.index });
1320 }
1321
1322 }
1323
1324 /**
1325 * Return the sum of values across an axis.

Callers

nothing calls this directly

Calls 3

indexOfMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected