Skip to main content

Search & Count

Functions that locate elements by position (argmin, argmax), compute order statistics (percentile, quantile), or count elements matching a condition.

argmin

Return the index of the minimum value along an axis.
Returns: number when no axis is specified and keepdims=false, NDArray of indices otherwise.

argmax

Return the index of the maximum value along an axis.
Returns: number when no axis is specified and keepdims=false, NDArray of indices otherwise.

percentile

Compute the q-th percentile of the data along the specified axis.
Returns: number for a scalar q over all axes, NDArray along a specific axis or with keepdims. An NDArray q gives an array of shape q.shape followed by the reduced shape (or q.shape followed by the keepdims shape); a 0-d q gives a 0-d NDArray.
Changed in v1.8.0: a NaN in the input now makes the result NaN, matching NumPy; previously NaN was sorted to the end and could be skipped. Use nanpercentile to ignore NaN. A q outside [0, 100] throws NumPy’s error message instead of the old “Quantile must be between 0 and 1”.

quantile

Compute the q-th quantile of the data along the specified axis. Equivalent to percentile but with q in the range [0, 1] instead of [0, 100].
Returns: number for a scalar q over all axes, NDArray along a specific axis or with keepdims. An NDArray q gives an array of shape q.shape followed by the reduced shape (or q.shape followed by the keepdims shape); a 0-d q gives a 0-d NDArray.
Changed in v1.8.0: a NaN in the input now makes the result NaN, matching NumPy; previously NaN was sorted to the end and could be skipped. Use nanquantile to ignore NaN. A q outside [0, 1] throws NumPy’s error message instead of the old “Quantile must be between 0 and 1”.

count_nonzero

Count the number of non-zero elements in the array.
Returns: number when counting over all axes, NDArray when counting along specific axes.