I tried np.where
but without success:
>>>a = np.array([np.nan, 1])
>>>np.where(a == np.nan)
(array([], dtype=int64),)
You need to change
np.where(a == np.nan)
to
np.where(np.isnan(a))
NaN values always return false in equality checks, even with another NaN value. So you need to use special functions to check for NaN like np.isnan.
import numpy as np
x = np.array([0,0,-1,1,np.nan, 0, 1, np.nan])
print np.where(np.isnan(x))
Returns:
(array([4, 7]),)