Counts the number of items a reduction with the same axis and skipna parameter values would use. The purpose of this function is for the creation of reduction operations which use the item count, such as mean.
When skipna is False or arr doesn’t have an NA mask, the result is simply the product of the reduction axis sizes, returned as a single scalar.
| Parameters : | arr : array_like
axis : None or int or tuple of ints, optional
skipna : bool, optional
keepdims : bool, optional
|
|---|---|
| Returns : | count : intp or array of intp
|
Examples
>>> a = np.array([[1,np.NA,1], [1,1,np.NA]])
>>> np.count_reduce_items(a)
6
>>> np.count_reduce_items(a, skipna=True)
4
>>> np.sum(a, skipna=True)
4
>>> np.count_reduce_items(a, axis=0, skipna=True)
array([2, 1, 1])
>>> np.sum(a, axis=0, skipna=True)
array([2, 1, 1])