0
假设我有以下数据框选择数据
df = DataFrame({'vals': [1, 2, 3, 4],
'ids': ['a', 'b', 'a', 'n']})
我要选择所有在列表中的行
[ (1,a), (3,f) ]
我一直在使用boolean indexing喜欢尝试所以
to_search = { 'vals' : [1,3],
'ids' : ['a', 'f']
}
df.isin(to_search)
我期望只有第一行匹配,但我得到的第一和第三行
ids vals
0 True True
1 True False
2 True True
3 False False
有没有什么办法可以准确地匹配特定索引的值而不是匹配任何值?