I am trying to convert the following dataframe:
cat userid val
1 1 10
1 2 15
1 3 22
2 1 33
2 2 54
2 3 44
to the following format: [[10, 15, 22], [33, 54, 44]]
This is my code:
df.groupby(['cat', 'userid'])['val'].apply(list)
And, this is what I get:
cat userid
1 1 [10]
2 [15]
3 [22]
2 1 [33]
2 [54]
3 [44]
Any suggestions?