python - How to get the indices list of all NaN value in numpy array? -
say have numpy array defined as,
[[1,2,3,4], [2,3,nan,5], [nan,5,2,3]]
now want have list contains indices of missing values, [(1,2),(2,0)]
@ case.
is there way can that?
np.isnan combined np.argwhere
x = np.array([[1,2,3,4], [2,3,np.nan,5], [np.nan,5,2,3]]) np.argwhere(np.isnan(x))
output:
array([[1, 2], [2, 0]])
Comments
Post a Comment