1

I have a dataframe like so:

df_ea = df_ea.loc[:,["DE","FR","IT","ES"]]
print(df_ea)

Country                     DE                 DE                 DE
location     Baden-Württemberg  Baden-Württemberg            Bavaria   
category    Grocery & pharmacy              Parks        Residential   
2020-02-23              35.763              5.449             -0.766   
2020-02-24              -1.295             43.503              3.573   
2020-02-25              -5.478             17.528              5.223   
2020-02-26              -2.533             -7.332              3.869   
2020-02-27              -1.698            -21.724               4.29   
2020-02-28               9.657              7.672              3.234   

I would like to filter this dataframe by location. I can do it when I enter one location, like so:

df_ea.loc[:,(df_ea=="Bavaria").any()]

But when I try to enter more than one, I get a TypeError:

df_ea.loc[:,(df_ea==(["Bavaria"|"Berlin"])).any()]
TypeError: unsupported operand type(s) for |: 'str' and 'str'

Is there any way to do this in python?

Nathan Thomas
  • 260
  • 1
  • 8

0 Answers0