【发布时间】:2020-09-08 13:03:45
【问题描述】:
在一个简单的 Pandas 系列中,当我比较 mul() 和 __mul__() 的结果时,会为 NaN 值返回一个“假”布尔值。
为什么?
x = pd.Series([0,1,2,np.nan,5])
x.mul(1) == x.__mul__(1)
Result:
0 True
1 True
2 True
3 False
4 True
dtype: bool
【问题讨论】:
-
NaN从不等于任何东西,甚至不等于它自己。这是其定义的一部分。 -
感谢@NateEldredge。这有帮助。