Pandas DataFrame - ' bool'对象不可订阅
我正在尝试在数据框架中检索记录,该记录在单独的列表中没有匹配的ID。本质上,我想从dataframe中删除唯一ID匹配列表pm_docids中的任何ID的任何记录:
df = df[~df['UniqueId']].isin((PM_docIDs).index, inplace=True)
这会产生以下错误:
In [35]:
Line 4: df = df[~df['UniqueId']].isin((PM_docIDs).index, inplace=True)
TypeError: 'bool' object is not subscriptable
是否有一种更轻松的方法来执行此操作,或者我可以做些什么来修复摘要Aboveso我不喜欢的摘要。 t获得typeError?
I am trying to retrieve records in a dataframe that do not have matching IDs in a separate list. Essentially, I want to drop any records from the dataframe where UniqueId matches any Ids in the list PM_docIDs:
df = df[~df['UniqueId']].isin((PM_docIDs).index, inplace=True)
This produces the following error:
In [35]:
Line 4: df = df[~df['UniqueId']].isin((PM_docIDs).index, inplace=True)
TypeError: 'bool' object is not subscriptable
Is there an easier way to do this or is there something I can do to fix the snippet aboveso I don't get the TypeError?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您很亲密,但是您的语法有些混乱。怎么样?
You're close, but your syntax is a little jumbled. How about this?