I have a column with in a dataframe that I want to filter the dataframe with based on which rows contain values that are in another dataframe.
In other words, I have a blacklist of keywords that I want to make sure are not in a dataframe.
To select rows whose column value is in an iterable, some_values
, use isin
:
df.loc[df['column_name'].isin(some_values)]
You can convert your whitelist of keywords to a set, and use the solution above. A similar question that I refer to is here.