dpnp.nanmean
- dpnp.nanmean(a, axis=None, dtype=None, out=None, keepdims=False, *, where=True)[source]
Compute the arithmetic mean along the specified axis, ignoring NaNs.
For full documentation refer to
numpy.nanmean
.- Parameters:
a ({dpnp.ndarray, usm_ndarray}) -- Input array.
axis ({None, int, tuple of ints}, optional) -- Axis or axes along which the arithmetic means must be computed. If a tuple of unique integers, the means are computed over multiple axes. If
None
, the mean is computed over the entire array. Default:None
.dtype ({None, dtype}, optional) -- Type to use in computing the mean. By default, if a has a floating-point data type, the returned array will have the same data type as a. If a has a boolean or integral data type, the returned array will have the default floating point data type for the device where input array a is allocated.
out ({None, dpnp.ndarray, usm_ndarray}, optional) -- Alternative output array in which to place the result. It must have the same shape as the expected output but the type (of the calculated values) will be cast if necessary. Default:
None
.keepdims ({None, bool}, optional) -- If
True
, the reduced axes (dimensions) are included in the result as singleton dimensions, so that the returned array remains compatible with the input array according to Array Broadcasting rules. Otherwise, ifFalse
, the reduced axes are not included in the returned array. Default:False
.
- Returns:
out -- An array containing the arithmetic means along the specified axis(axes). If the input is a zero-size array, an array containing NaN values is returned. In addition, NaN is returned for slices that contain only NaNs.
- Return type:
dpnp.ndarray
Limitations
Parameter where is only supported with its default value. Otherwise
NotImplementedError
exception will be raised.See also
dpnp.average
Weighted average.
dpnp.mean
Compute the arithmetic mean along the specified axis.
dpnp.var
Compute the variance along the specified axis.
dpnp.nanvar
Compute the variance along the specified axis, while ignoring NaNs.
dpnp.std
Compute the standard deviation along the specified axis.
dpnp.nanstd
Compute the standard deviation along the specified axis, while ignoring NaNs.
Examples
>>> import dpnp as np >>> a = np.array([[1, np.nan], [3, 4]]) >>> np.nanmean(a) array(2.6666666666666665) >>> np.nanmean(a, axis=0) array([2., 4.]) >>> np.nanmean(a, axis=1) array([1., 3.5]) # may vary