I have this dataframe:
d = {'city':['Barcelona','Madrid','Rome','Torino','London','Liverpool','Manchester','Paris'],
'country': ['ES','ES','IT','IT','UK','UK','UK','FR'],
'revenue': [1,2,3,4,5,6,7,8],
'amount': [8,7,6,5,4,3,2,1]
df = pd.DataFrame(d)
I want to obtain this for each country:
españa = {'city':['Barcelona','Madrid']
'revenue':[1,2]
'amount':[8,7]}
ES = pd.DataFrame(españa)
So that in the end I will have 4 dataframes named ES,IT,UK and FR.
I have tried this so far:
a = set(df.loc[:]["country"])
for country in a:
country = df.loc[(df["country"]== country),['date','sum']]
But that only gave me one dataframe with one value.