I have a dataframe which is essentially daily imports for each country in a given area. I need to make a new dataframe for each country.
Example;
Spain = df[['Date', 'Spain']]
Spain['Date']= pd.to_datetime(Spain['Date'])
Spain = Spain.groupby([Spain.Date.dt.year,Spain.Date.dt.month]).mean()
Spain = Spain.unstack()
Spain = Spain/1745
Spain = Spain.round()
I am not very experienced with loops but is there any way I could create a list of all the countries and make a loop that would loop through that list to save me from writing the above code for each of the 100+ countries?
Any help much appreciated.