numpy.nanmin

numpy.nanmin(a, axis=None)

Return the minimum of array elements over the given axis ignoring any NaNs.

Parameters:

a : array_like

Array containing numbers whose sum is desired. If a is not an array, a conversion is attempted.

axis : int, optional

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

Returns:

y : {ndarray, scalar}

An array with the same shape as a, with the specified axis removed. If a is a 0-d array, or if axis is None, a scalar is returned. The the same dtype as a is returned.

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, an integer type is returned unless the input contains NaNs and infinity.

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

Quick search