使用'在'中对Pandas数据帧执行布尔掩码的Pythonic方法是什么?操作者

时间:2017-05-17 18:24:01

标签: python pandas dataframe

这失败了:

blargh = ['38382', '42132']
dfnew = df[df['FVID'] in blargh]

消息:

C:\Anaconda2\lib\site-packages\pandas\core\ops.py:792: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison result = getattr(x, name)(y)

让这个布尔掩码工作的Pythonic方法是什么?

1 个答案:

答案 0 :(得分:2)

您正在寻找pandas dataframe.isin()

dfnew = df[df['FVID'].isin( blargh)]