numpy.nanmin

numpy.nanmin(a, axis=None)

Return the minimum of an array or minimum along an axis ignoring any NaNs.

Parameters :

a : array_like

Array containing numbers whose minimum is desired.

axis : int, optional

Axis along which the minimum is computed.The default is to compute the minimum of the flattened array.

Returns :

nanmin : ndarray

A new array or a scalar array with the result.

See also

numpy.amin
Minimum across array including any Not a Numbers.
numpy.nanmax
Maximum across array ignoring any Not a Numbers.
isnan
Shows which elements are Not a Number (NaN).
isfinite
Shows which elements are not: Not a Number, positive and negative infinity

Notes

Numpy uses the IEEE Standard for Binary Floating-Point for Arithmetic (IEEE 754). This means that Not a Number is not equivalent to infinity. Positive infinity is treated as a very large number and negative infinity is treated as a very small (i.e. negative) number.

If the input has a integer type the function is equivalent to np.min.

Examples

>>> a = np.array([[1, 2], [3, np.nan]])
>>> np.nanmin(a)
1.0
>>> np.nanmin(a, axis=0)
array([ 1.,  2.])
>>> np.nanmin(a, axis=1)
array([ 1.,  3.])

When positive infinity and negative infinity are present:

>>> np.nanmin([1, 2, np.nan, np.inf])
1.0
>>> np.nanmin([1, 2, np.nan, np.NINF])
-inf

Previous topic

numpy.nanmax

Next topic

numpy.ptp

This Page