Hi I want to filter a large dataframe based on if a columns row is in a list object.
I tried the code below but i get an error:
df[df['castaway_id'] in [1,2,3,4]]
Is there an alternative to this or another way to do the same
Hi I want to filter a large dataframe based on if a columns row is in a list object.
I tried the code below but i get an error:
df[df['castaway_id'] in [1,2,3,4]]
Is there an alternative to this or another way to do the same
Yes, the usual way is to use the isin
method as below :
df[df['castaway_id'].isin([1,2,3,4])]