Please click on the image to understand better ^^
brands is a numpy array with 2314 elements. I am checking if there is a nan value in the array. The output shows false but when I tried intersection function with np.nan, it shows the common element as nan. So how come I cant find the nan value in array? And how do I remove it?
CodePudding user response:
NaN is not equal with itself.
>>> np.nan != np.nan
True
You can use numpy.isnan
to check
np.isnan(brands)
CodePudding user response:
The issue is that numpy's nan cannot be compared to itself, or in other words numpy.nan == numpy.nan
returns False. Use instead numpy.isnan()
.