Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas filter dataframe if an elemnt is in alist

In [30]:
df[df['id'].isin(['foo','bar'])]

Out[30]:
   value   id
0      1  foo
1      2  bar
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #filter #dataframe #elemnt #alist
ADD COMMENT
Topic
Name
1+6 =