0

Trying to get my head around this...

a = float("NaN")

a == float("NaN")

Out: False

np.isnan(a)

Out: True

Daniel Hao
  • 4,922
  • 3
  • 10
  • 23
Luis P
  • 21
  • 5
  • 8
    Because `NaN` is not equal to anything, including itself. By definition. – tkausl Jul 17 '22 at 15:32
  • NaN is effectively a null value: https://wiki.dataself.com/NULL_Values – Barry Carter Jul 17 '22 at 15:34
  • 1
    Related post - https://stackoverflow.com/questions/944700/ – Daniel Hao Jul 17 '22 at 15:36
  • There are really many different not-a-number values, `float("NanN")` just produces one of them. One of the more significant consequences of using inband signaling of errors is that floating-point equality is *not* an [equivalence relation](https://en.wikipedia.org/wiki/Equivalence_relation), because reflexivity is not respected. – chepner Jul 17 '22 at 15:41

1 Answers1

0

"NaN" means that it isn't equal to anything. So {thing1 which is NaN} == {thing2 which is NaN} will always be "False" because NaN is not equal to anything, including itself.

Daisy Welham
  • 225
  • 1
  • 10