使用pandas从数据框中使用两个不同的列来选择行?

使用pandas从数据框中使用两个不同的列来选择行?,第1张

使用pandas从数据框中使用两个不同的列来选择行?

您几乎拥有它,但是必须使用“按位或”运算符:

In [6]: df[(df.one == 1) | (df.two == 7)]Out[6]:    one  three  two0    1      9    52    3     17    7In [7]: df[(df.one.isin(checkList)) | (df.two.isin(checkList))]Out[7]:    one  three  two0    1      9    52    3     17    7


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5655229.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存