Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between nan, NaN and NAN

Tags:

python

nan

numpy

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?

like image 210
sashkello Avatar asked Jul 24 '13 05:07

sashkello


People also ask

Is NaN and NP NaN same?

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 .

Does NaN mean None?

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.

Is NP NaN NP NaN?

nan is also False . But testing identity with is , np. nan is np. NaN is True .

Is NaN equal to itself?

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.


1 Answers

>>> numpy.nan is numpy.NaN is numpy.NAN True 

It's just convenient. They're exactly the same.

like image 70
user2357112 supports Monica Avatar answered Sep 24 '22 09:09

user2357112 supports Monica