* Return minimum of values in a DataFrame across specified axis. * @param options.axis 0 or 1. If 0, compute the minimum value column-wise, if 1, row-wise. Defaults to 1 * @example * ``` * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']}) * df.min().print()
(options?: { axis?: 0 | 1 })
| 935 | * ``` |
| 936 | */ |
| 937 | min(options?: { axis?: 0 | 1 }): Series { |
| 938 | const { axis } = { axis: 1, ...options } |
| 939 | |
| 940 | if (this.$frameIsNotCompactibleForArithmeticOperation()) { |
| 941 | throw Error("TypeError: min operation is not supported for string dtypes"); |
| 942 | } |
| 943 | |
| 944 | if ([0, 1].indexOf(axis) === -1) { |
| 945 | throw Error("ParamError: Axis must be 0 or 1"); |
| 946 | } |
| 947 | |
| 948 | const newData = this.$getDataByAxisWithMissingValuesRemoved(axis) |
| 949 | |
| 950 | const resultArr = newData.map(arr => { |
| 951 | let smallestValue = arr[0] |
| 952 | for (let i = 0; i < arr.length; i++) { |
| 953 | smallestValue = smallestValue < arr[i] ? smallestValue : arr[i] |
| 954 | } |
| 955 | return smallestValue |
| 956 | }) |
| 957 | if (axis === 0) { |
| 958 | return new Series(resultArr, { index: this.columns }); |
| 959 | } else { |
| 960 | return new Series(resultArr, { index: this.index }); |
| 961 | } |
| 962 | } |
| 963 | |
| 964 | /** |
| 965 | * Return maximum of values in a DataFrame across specified axis. |
nothing calls this directly
no test coverage detected