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

Method max

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

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

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

Source from the content-addressed store, hash-verified

976 * ```
977 */
978 max(options?: { axis?: 0 | 1 }): Series {
979 const { axis } = { axis: 1, ...options }
980
981 if (this.$frameIsNotCompactibleForArithmeticOperation()) {
982 throw Error("TypeError: max operation is not supported for string dtypes");
983 }
984
985 if ([0, 1].indexOf(axis) === -1) {
986 throw Error("ParamError: Axis must be 0 or 1");
987 }
988
989 const newData = this.$getDataByAxisWithMissingValuesRemoved(axis)
990
991 const resultArr = newData.map(arr => {
992 let biggestValue = arr[0]
993 for (let i = 0; i < arr.length; i++) {
994 biggestValue = biggestValue > arr[i] ? biggestValue : arr[i]
995 }
996 return biggestValue
997 })
998 if (axis === 0) {
999 return new Series(resultArr, { index: this.columns });
1000 } else {
1001 return new Series(resultArr, { index: this.index });
1002 }
1003
1004 }
1005
1006 /**
1007 * Return standard deviation of values in a DataFrame across specified axis.

Callers

nothing calls this directly

Calls 4

indexOfMethod · 0.80
mapMethod · 0.65

Tested by

no test coverage detected