dpnp.nanprod
- dpnp.nanprod(a, axis=None, dtype=None, out=None, keepdims=False, initial=None, where=True)[source]
Return the product of array elements over a given axis treating Not a Numbers (NaNs) as ones.
For full documentation refer to
numpy.nanprod.- Returns:
out – A new array holding the result is returned unless out is specified, in which case it is returned.
- Return type:
dpnp.ndarray
See also
dpnp.prodReturns product across array propagating NaNs.
dpnp.isnanTest element-wise for NaN and return result as a boolean array.
Limitations
Input array is only supported as either
dpnp.ndarrayordpctl.tensor.usm_ndarray. Parameters initial, and where are only supported with their default values. Otherwise the function will be executed sequentially on CPU. Input array data types are limited by supported DPNP Data types.Examples
>>> import dpnp as np >>> np.nanprod(np.array(1)) array(1) >>> np.nanprod(np.array([1])) array(1) >>> np.nanprod(np.array([1, np.nan])) array(1.0) >>> a = np.array([[1, 2], [3, np.nan]]) >>> np.nanprod(a) array(6.0) >>> np.nanprod(a, axis=0) array([3., 2.])