1

Let's say I have a pandas dataframe with some nan values. Every time I do something like df["column"] == np.nan, it always returns all False. It never returns True even though there are obvoiusly nan. I mean even this returns all false:

np.full(5, np.nan) == np.nan

Why?

  • Because [np.nan != np.nan](https://pandas.pydata.org/pandas-docs/stable/user_guide/missing_data.html#values-considered-missing). – Henry Yik Apr 14 '20 at 06:56
  • It's part of the C-heritage of Python: `NaN==NaN` equals `False`, and that's typically how you check for NaNs in C/C++. – Learning is a mess Apr 14 '20 at 08:24

0 Answers0