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 change the array at all. Why is that?
I have an array A on python that has some nan values created by
Share
You want
np.isnan:The problem with your code is that (according to IEEE),
nandoesn’t equal anything — even itself.As a side note, there’s also
np.isinf-> (+/- infinity)np.isfinite-> (not infinity or NaN)np.isposinf-> (+ infinity)np.isneginf-> (- infinity)