I am using Python and Pandas. I have a df that works similar to this:
 +--------+--------+-------+
 |  Col1  |  Col2  | Col3 |
 +--------+--------+-------+
 | Team 1 | High   | Pizza |
 | Team 1 | Medium | Sauce |
 | Team 1 | Low    | Crust |
 +--------+--------+-------+
I would like to filter the df so that I only see High or Medium from Col2.
This is what I have tried with no luck
 df = df.loc[df['Col2'] == 'High' | (df['Col2'] == 'Medium')]
This is the error I am getting
 cannot compare a dtyped [bool] array with a scalar of type [bool]
Any ideas how to make this work and what that error means?
This works as well, more pythonic
country_list = ['brazil','poland','russia','countrydummy','usa']
filtered_df = df[df['Country Name'].isin(country_list)]
print(filtered_df )
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With