- numpy.nanmax(a, axis=None, out=None, keepdims=<class numpy._globals._NoValue at 0x40b6a26c>)¶
Return the maximum of an array or maximum along an axis, ignoring any NaNs. When all-NaN slices are encountered a RuntimeWarning is raised and NaN is returned for that slice.
a : array_like
Array containing numbers whose maximum is desired. If a is not an array, a conversion is attempted.
axis : int, optional
Axis along which the maximum is computed. The default is to compute the maximum of the flattened array.
out : ndarray, optional
Alternate output array in which to place the result. The default is None; if provided, it must have the same shape as the expected output, but the type will be cast if necessary. See doc.ufuncs for details.
New in version 1.8.0.
keepdims : bool, optional
If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original a.
If the value is anything but the default, then keepdims will be passed through to the max method of sub-classes of ndarray. If the sub-classes methods does not implement keepdims any exceptions will be raised.
New in version 1.8.0.
nanmax : ndarray
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, an ndarray scalar is returned. The same dtype as a is returned.
- The minimum value of an array along a given axis, ignoring any NaNs.
- The maximum value of an array along a given axis, propagating any NaNs.
- Element-wise maximum of two arrays, ignoring any NaNs.
- Element-wise maximum of two arrays, propagating any NaNs.
- Shows which elements are Not a Number (NaN).
- Shows which elements are neither NaN nor infinity.
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.max.
>>> a = np.array([[1, 2], [3, np.nan]]) >>> np.nanmax(a) 3.0 >>> np.nanmax(a, axis=0) array([ 3., 2.]) >>> np.nanmax(a, axis=1) array([ 2., 3.])
When positive infinity and negative infinity are present:
>>> np.nanmax([1, 2, np.nan, np.NINF]) 2.0 >>> np.nanmax([1, 2, np.nan, np.inf]) inf