I have a dataset that looks like this:
I need to transform it so it looks like this:
Meaning I need to show the balance by balance groups and time gaps.
Now the time gaps are elements of a column. I tried to use the following;
b = a.pivot_table(values='GAP', index=a.index, columns='BALANCE_GROUP', aggfunc='first')
With different parameters but it outputs something really weird. I also tried to use the groupby function which works fine, but it won't allow me to set the elements in the gap column as seperate columns...
b = a.groupby(['BALANCE_GROUP','GAP']).sum()
and I got something like this: