I currently have a dataframe that looks like this :
df = pd.DataFrame({'A': [1,1,2,2,2,2,3],
'B':['a','b','c','d','e','f','g'],
'C':['1','2','3','4','5','6','7']})
df2 = df.groupby('A')['B'].apply(list).reset_index() produces this :
A B
0 1 [a, b]
1 2 [c, d, e, f]
2 3 [g]
How can I produce this?
A B C
0 1 [a, b] [1, 2]
1 2 [c, d, e, f] [3, 4, 5, 6]
2 3 [g] [7]