13.09.2024 - nan.txt
Funny thing about the not a number (nan) implementation in numpy.
>>> import numpy as np
>>> np.nan is np.NaN is np.NAN
True
>>> np.nan == np.NaN == np.NAN
False
Which makes sense, because nan is never equal to anything, but any nan *is* any other implementation of it.
Moral of the story: don't assign stuff with
arr[arr==np.nan]=x
. It won't work. Use np.isnan(x)
.