how many nan in array python

np.count_nonzero(~np.isnan(data))

Here is what the above code is Doing:
1. We’re using the ~ operator to invert the logical expression.
2. We’re using the np.isnan function to check if the data is NaN.
3. We’re using the np.count_nonzero function to count the number of non-NaN values.