An alternative, but a bit slower alternative is to do it over indexing.
np.isnan(data)[np.isnan(data) == False].size
In [30]: %timeit np.isnan(data)[np.isnan(data) == False].size
1 loops, best of 3: 498 ms per loop
The double use of np.isnan(data)
and the ==
operator might be a bit overkill and so I posted the answer only for completeness.