Select subset of Data Frame rows based on a list in Pandas
Use isin
to return a boolean index for you to index into your df:
In [152]:
df1[df1['A'].isin(x)]
Out[152]:
A B C
1 b 12 1
2 c 14 2
This is what isin
is returning:
In [153]:
df1['A'].isin(x)
Out[153]:
0 False
1 True
2 True
3 False
4 False
Name: A, dtype: bool