此问题在此处已有答案:
Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()(13个答案)
Filtering Pandas Dataframe using OR statement(3个答案)
21小时前关门了。
我有这样的 Dataframe :
id check_id
1 10
1 100
2 10
3 34
4 12
1 101
和列表:
list=[10,101]
我尝试过滤这个df,如下所示:
df[(df['id']==1) and (df['check_id'].isin(list))]
要获得此输出,请执行以下操作:
id check_id
1 10
1 101
但我收到此错误消息:
The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
我一直在尝试解决这个问题,但到目前为止还没有成功。
我该如何修复它?
2条答案
按热度按时间zhte4eai1#
如果你搜索而不是问问题,你会很容易得到答案
b1payxdu2#
参照this article,查询应为: