I have a dataframe like this (group by Col1,col2 and sort on col4,
df = Col1 col2 col3 col4
1. A B 1 5
2. A B 1 6
3. X Y 2 1
4. X Y 3 2
What I want is something like this
col1 col2 col3 col4
A B [1,1] [5,6]
X Y [2,3] [1,2]
but unable to concatenate the col3.
I am able to do groupby and sort by col1,col2.
df =df.groupby(['col1','col2']).apply(lambda x: x.sort_values('col4'))