When I check for equality and identity of Python operands e.g. a = []; b = a
I get this:
a == b => True
a is b => True
and I understand it.
so, why I am getting diff result with np.nan?:
a = np.nan; b = a
a == b => False
a is b => True
?
When I check for equality and identity of Python operands e.g. a = []; b = a
I get this:
a == b => True
a is b => True
and I understand it.
so, why I am getting diff result with np.nan?:
a = np.nan; b = a
a == b => False
a is b => True
?
Because NaN
is never equal to anything else, and
we use ==
for performing an equality comparison.
On the other hand the object used to represent NaN
is identical to itself, because is
is used for doing an identity comparison.