0

I have problem by detecting 'nan' in pandas dataframe if column is float64 data type. Both comparsion operators ('nan' == for 'nan', 'NaN', np.nan) and functions sucha as .isnull() do not work.

Moreover this making me crazy:

np.float64(np.nan) == np.float64(np.nan)

out: False

Can anyone explain that issue?

DamianJot
  • 41
  • 4
  • 1
    Related: [Why NaN not equal to NaN?](https://stackoverflow.com/q/10034149/12416453) – Ch3steR Dec 30 '20 at 13:13
  • 1
    Another related: [Why `np.nan == np.nan` is `False`?](https://stackoverflow.com/q/20320022/12416453) – Ch3steR Dec 30 '20 at 13:14
  • 1
    From [docs](https://numpy.org/doc/stable/user/misc.html) `np.nan == np.nan # is always False! Use special numpy functions instead` – Ch3steR Dec 30 '20 at 13:15
  • 1
    Following above comments, `pd.isna()` is also useful, especially for Pandas objects (dataframes and series). – itaishz Dec 30 '20 at 13:35
  • just need to use logic / philosophy. Are the things you don't know the same as the things I don't know. They are not, therefore in general case unknown is is not equal to another unknown. Similar to in mathematics infinite is not the same as any infinite – Rob Raymond Dec 30 '20 at 13:57

0 Answers0