pandas filter rows that are in a list
value_list = ["apple"] boolean_series = df.fruit.isin(value_list) filtered_df = df[boolean_series]
Here is what the above code is Doing:
1. Create a list of values that we want to filter by.
2. Create a boolean series that is True when the value is in the list.
3. Use the boolean series to filter the dataframe.