我目前正在使用 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
好吧,我已经知道我原来的问题的解决方案,我只是好奇为什么会发生这种情况