小编Rol*_*ong的帖子

为什么“不是无”与 dataframe.loc 一起工作,但“!=无”工作正常?

我目前正在使用 Pandas 数据框,我想选择数据框中没有 None 实体属性的所有数据条目。

df_ = df.loc[df['entities'] != None]
Run Code Online (Sandbox Code Playgroud)

似乎工作得很好但是

df_ = df.loc[df['entities'] is not None]
Run Code Online (Sandbox Code Playgroud)

将引发 KeyError 是

文件“pandas_libs\index.pyx”,第 107 行,>pandas._libs.index.IndexEngine.get_loc 文件“pandas_libs\index.pyx”,第 128 行,>pandas._libs.index.IndexEngine.get_loc 文件“pandas_libs\ index_class_helper.pxi”,第 91 行,在 >pandas._libs.index.Int64Engine._check_type KeyError: True

好吧,我已经知道我原来的问题的解决方案,我只是好奇为什么会发生这种情况

python pandas

5
推荐指数
2
解决办法
3343
查看次数

标签 统计

pandas ×1

python ×1