In pure Python, None or True
returns True
.
However with pandas when I'm doing a |
between two Series containing None values, results are not as I expected:
>>> df.to_dict()
{'buybox': {0: None}, 'buybox_y': {0: True}}
>>> df
buybox buybox_y
0 None True
>>> df['buybox'] = (df['buybox'] | df['buybox_y'])
>>> df
buybox buybox_y
0 False True
预期结果:
>>> df
buybox buybox_y
0 True True
通过两次应用OR运算,我得到了想要的结果,但我不明白为什么要这样做.
我不是在寻找一个解决方法(我通过连续两次申请df['buybox'] = (df['buybox'] | df['buybox_y'])
个),而是一个解释,也就是标题中的"为什么".