I have a 2D numpy array. Some of the values in this array are NaN. I want to perform certain operations using this array. For example consider the array:
NaN
This should work:
from numpy import * a = array([[1, 2, 3], [0, 3, NaN]]) where_are_NaNs = isnan(a) a[where_are_NaNs] = 0
In the above case where_are_NaNs is:
In [12]: where_are_NaNs Out[12]: array([[False, False, False], [False, False, True]], dtype=bool)