I'm tryng to reverse this but I can't figure out how. I'm starting from
>>> d = {'col1': ['A', 'A', 'A', 'B', 'B', 'B', 'C', 'C'], 'col2': [1, 2, 3, 4, 5, 6, 7, 7]}
>>> df = pd.DataFrame(data=d)
>>> df
col1 col2
0 A 1
1 A 2
2 A 3
3 B 4
4 B 5
5 B 6
6 C 7
7 C 7
And I want to obtain:
col1 new_1 new_2 new_3
0 A 1 2 3
1 B 4 5 6
2 C 7 7 empty
where there are new_x columns based on max number of times a col1 item is repeated. It seems to be a pretty standard transpose, but I can't find a solution.
Sorry if duplicated.
Thx Sirius