numpy.nanprod() is used when we want to compute the product of array elements along a given axis, treating
NaNs . One is returned for slices that are all NaN or empty.
Syntax: numpy.nanprod (arr, axis = None, dtype = None, out = None, keepdims = 'class numpy._globals._NoValue').
arr: [array_like] Array containing numbers whose sum is desired ... If arr is not an array, a conversion is attempted.
axis: Axis along which the product is computed. The default is to compute the product of the flattened array.
dtype: The type of the returned array and of the accumulator in which the elements are summed. By default, the dtype of arr is used.
out: [ndarray, optional] A location into which the result is stored.
- & gt ; If provided, it must have a shape that the inputs broadcast to.
- & gt; If not provided or None, a freshly-allocated array is returned.
keepdims: 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 arr.
Return: A new array holding the result is returned unless out is specified, in which case it is returned.
Code # 1: Work
Input number: 10 product of array element: 10
Code # 2:
| tr> |
Input array: [[2. 2. 2 .] [2. 2. nan]] product of array elements: 32.0
Code # 3:
Input array: [[2. 2. 2.] [2. 2. nan]] product of array elements taking axis 1: [8. 4.]
Since you are interested in learning more about designing data visualizations (by virtue of the fact that you’re reading this book), then chances are good that you have been the reader of other peop...
Professional-quality code does more than just run without bugs. It’s clean, readable, and easy to maintain. To step up from a capable Python coder to a professional developer, you need to learn indu...
R for Everyone: Advanced Analytics and Graphics. ...
In Learn Python 3 the Hard Way PDF, you'll learn Python by working through 52 brilliantly crafted exercises. Read them. Enter your code exactly. (No copying and pasting!) Correct your mistakes. ...