Return the product of array elements over a given axis treating Not a Numbers (NaNs) as ones. One is returned for slices that are all-NaN or empty. Parameters ---------- a : array_like Array containing numbers whose product is desired. If `a` is not an arra
(a, axis=None, dtype=None, out=None, keepdims=np._NoValue,
initial=np._NoValue, where=np._NoValue)
| 734 | |
| 735 | @array_function_dispatch(_nanprod_dispatcher) |
| 736 | def nanprod(a, axis=None, dtype=None, out=None, keepdims=np._NoValue, |
| 737 | initial=np._NoValue, where=np._NoValue): |
| 738 | """ |
| 739 | Return the product of array elements over a given axis treating Not a |
| 740 | Numbers (NaNs) as ones. |
| 741 | |
| 742 | One is returned for slices that are all-NaN or empty. |
| 743 | |
| 744 | Parameters |
| 745 | ---------- |
| 746 | a : array_like |
| 747 | Array containing numbers whose product is desired. If `a` is not an |
| 748 | array, a conversion is attempted. |
| 749 | axis : {int, tuple of int, None}, optional |
| 750 | Axis or axes along which the product is computed. The default is to compute |
| 751 | the product of the flattened array. |
| 752 | dtype : data-type, optional |
| 753 | The type of the returned array and of the accumulator in which the |
| 754 | elements are summed. By default, the dtype of `a` is used. An |
| 755 | exception is when `a` has an integer type with less precision than |
| 756 | the platform (u)intp. In that case, the default will be either |
| 757 | (u)int32 or (u)int64 depending on whether the platform is 32 or 64 |
| 758 | bits. For inexact inputs, dtype must be inexact. |
| 759 | out : ndarray, optional |
| 760 | Alternate output array in which to place the result. The default |
| 761 | is ``None``. If provided, it must have the same shape as the |
| 762 | expected output, but the type will be cast if necessary. See |
| 763 | :ref:`ufuncs-output-type` for more details. The casting of NaN to integer |
| 764 | can yield unexpected results. |
| 765 | keepdims : bool, optional |
| 766 | If True, the axes which are reduced are left in the result as |
| 767 | dimensions with size one. With this option, the result will |
| 768 | broadcast correctly against the original `arr`. |
| 769 | initial : scalar, optional |
| 770 | The starting value for this product. See `~numpy.ufunc.reduce` |
| 771 | for details. |
| 772 | |
| 773 | .. versionadded:: 1.22.0 |
| 774 | where : array_like of bool, optional |
| 775 | Elements to include in the product. See `~numpy.ufunc.reduce` |
| 776 | for details. |
| 777 | |
| 778 | .. versionadded:: 1.22.0 |
| 779 | |
| 780 | Returns |
| 781 | ------- |
| 782 | nanprod : ndarray |
| 783 | A new array holding the result is returned unless `out` is |
| 784 | specified, in which case it is returned. |
| 785 | |
| 786 | See Also |
| 787 | -------- |
| 788 | numpy.prod : Product across array propagating NaNs. |
| 789 | isnan : Show which elements are NaN. |
| 790 | |
| 791 | Examples |
| 792 | -------- |
| 793 | >>> import numpy as np |
nothing calls this directly
no test coverage detected
searching dependent graphs…