I am just trying to do the following exercise: I want to use the values of column A as an aggregator for Column B, but instead of using a function like "sum" or "mean", I want to have the values side by side. let me give you an example.
Before:
d = {'A': [0,1,2,3,4,0,1,2,3,4],
'B': [10,11,17,13,15,2,3,19,20,21]}
df = pd.DataFrame(d)
df
A B
0 10
1 11
2 17
3 13
4 15
0 2
1 3
2 19
3 20
4 21
How I would like to see it:
A D E
0 10 2
1 11 3
2 17 19
3 13 20
4 15 21
In my head, the solution would be using unstack
or maybe a groupby
, but I can't think of how to formulate it.
Thanks