本文介绍了python np.nan和'=='&'是'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我检查Python操作数的相等性和同一性时,例如 a = [];b = a
我明白了:
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
我理解.
那么,为什么我要用np.nan获得差异结果?:
so, why I am getting diff result with np.nan?:
a = np.nan; b = a
a == b => False
a is b => True
?
推荐答案
因为 NaN
从不等于任何其他,并且我们使用 ==
进行平等比较.
Because NaN
is never equal to anything else, andwe use ==
for performing an equality comparison.
另一方面,用于表示 NaN
的 object 与自身相同,因为 is
用于执行身份比较.
On the other hand the object used to represent NaN
is identical to itself, because is
is used for doing an identity comparison.
这篇关于python np.nan和'=='&'是'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!