I have an array A on python that has some nan values created by numpy.nan. I want to set all the nan values to zero using A[A==numpy.nan] = 0. It doesn\'t chang
A[A==numpy.nan] = 0
You want np.isnan:
A[np.isnan(A)] = 0
The problem with your code is that (according to IEEE), nan doesn't equal anything -- even itself.
nan
As a side note, there's also
np.isinf
np.isfinite
np.isposinf
np.isneginf