In numpy there are nan
, NaN
and NAN
. What's the sense of having all three, do they differ or any of these can be used interchangeably?
nan is a single object that always has the same id, no matter which variable you assign it to. np. nan is np. nan is True and one is two is also True .
NaN can be used as a numerical value on mathematical operations, while None cannot (or at least shouldn't). NaN is a numeric value, as defined in IEEE 754 floating-point standard. None is an internal Python type ( NoneType ) and would be more like "inexistent" or "empty" than "numerically invalid" in this context.
nan is also False . But testing identity with is , np. nan is np. NaN is True .
Yeah, a Not-A-Number is Not equal to itself. But unlike the case with undefined and null where comparing an undefined value to null is true but a hard check(===) of the same will give you a false value, NaN's behavior is because of IEEE spec that all systems need to adhere to.
>>> numpy.nan is numpy.NaN is numpy.NAN True
It's just convenient. They're exactly the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With