I have some data in a list format: figures for 150-odd organisations, with a figure for each of a 12-month series. In its raw form it looks like this:
Name Size Date Figure
Org1 Medium Jun16 8.36
Org1 Medium Jul16 7.55
Org1 Medium Aug16 8.57
...
Org1 Medium May17 9.41
Org2 Large Jun16 12.12
Org2 Large Jul16 11.44
...
So each organisation has a unique name, twelve months of data, and one of three sizes (small, medium, large). I've successfully pivoted these figures to give me a timeseries for each organisation, i.e.,
Name Jun16 Jul16 Aug16 Sep16 Oct16...
Org1 8.36 7.55 8.57 7.66 9.43
Org2 12.12 11.44 11.01 12.01 10.44...
But I want to include another column containing the size of each organisation. The code I've used for the pivot is:
dataPivot = dataRaw.pivot_table(index='Name', columns ='Date'],
aggfunc='sum', values = 'Figure').fillna(0)
where dataRaw is the raw data read in from a .csv. I've tried adding 'Size' to the columns field, but this just gives me 12 additional columns for each size!