count number of elements in a numpy array code example
Example 1: how to count positive elements numpy
>>> np.sum(np.array(x) > 0, axis=0)
array([3, 3, 3, 3, 3, 0])
Example 2: numpy count where
print(np.sum(a % 2 == 1))
>>> np.sum(np.array(x) > 0, axis=0)
array([3, 3, 3, 3, 3, 0])
print(np.sum(a % 2 == 1))