I am having an issue plotting groupby data in python using matplotlib and would appreciate some help as I a new to python.
Aim: plot total incidents of flytipping in England (y-axis) by Time Period (x-axis) grouped by region.
First of all I subset my data:
##Total Per Region
TotalPerRegion=data[(data['LA_Name']=='Total') & (data['Region'] != 'TotalEngland')]
Transform the data and group by region
TotalPerRegion=TotalPerRegion.groupby(['Year','Region'])['Total_Incidents'].sum().unstack(level='Region')
OutputRegion East East Midlands London North East North West South East \
Year
2012-13 56484 40059 231894 56748 105201 66710
2013-14 63829 44747 327484 50467 113596 70029
2014-15 68373 48946 367075 50837 108536 74484
2015-16 69461 50694 320137 48067 117529 69315
2016-17 75447 60969 349878 53005 128193 79911
2017-18 72832 68470 284250 62037 111920 79307
2018-19 67792 69237 324261 63646 112069 83752
Region South West Total England West Midlands Yorkshire and The Humber
Year
2012-13 45182 714637 46425 57536
2013-14 53433 857655 56880 67391
2014-15 56166 905604 56895 66051
2015-16 34390 941896 56466 68883
2016-17 44745 1011199 63806 76545
2017-18 56563 997553 59593 86697
2018-19 59334 1072431 65379 97649
Then try to plot the data:
fig, ax = plt.subplots()
TotalPerRegion.plot()
This error then appears:
raise TypeError("no numeric data to plot")
TypeError: no numeric data to plot
Can anyone provide any help to solve the problem? Thanks.