这失败了:
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方法是什么?
答案 0 :(得分:2)
您正在寻找pandas dataframe.isin()
dfnew = df[df['FVID'].isin( blargh)]