It's a generic question about filtering a pandas dataframe using a list. The problem is the following:
- I have a pandas dataframe
dfwith a columnfield - I have a list of banned fields, for example
ban_field=['field1','field2','field3'] - All elements of
ban_fieldappear indf.field
For the moment, to retrieve the dataframe without the banned field, I proceed as follows:
for f in ban_field:
df = df[df.field!=f]
Is there a more pythonic way to proceed (in one line?)?