First, you need to be able to access just the column that you're interested in. Do this with a slice:
data[:,2] # grab all rows, and just the column with index 2
Now you want to count the occurrences that are NaN:
np.count_nonzero(np.isnan(data[:,2]))
And we want to count the number of zero elements:
data[:,2].size - np.count_nonzero(data[:,2])
And if we add those together:
data[:,2].size - np.count_nonzero(data[:,2]) + np.count_nonzero(np.isnan(data[:,2]))
This is boring, though, since the 3rd column doesn't have any 0 or NaN in it. Lets try with the last column:
>>> slice = data[:,3]
>>> slice.size - np.count_nonzero(slice) + np.count_nonzero(np.isnan(slice))
3
edit I should explain why this works:
np.isnan(data[:,2]) gives an array of True and False based on if it's a NaN or not. True, when treated as a number, is converted to 1 and False is converted to0so thenp.count_nonzerocall counts the number of1which represent theNaN` values.
np.count_nonzero(data[:,2]) counts the number of non-zero directly. If we subtract the number of non-zero elements from the total number of elements, we'll get the number of 0s.
data = np.array([[ 1, 2000, 143, 4546], [ 2, 1999, 246, 0], [ 3, 2008, 190, np.NAN ], [ 4, 2000, 100, 0]])""which is a string. The blank would have to be interpreted as a NaN.