I have a dataframe like below and I want to add a column 'ratings_list' that groups by id and puts the ratings into a list where the list index is the item number
id | item | rating
1 | 1 | 5
1 | 2 | 4
1 | 4 | 5
1 | 7 | 3
2 | 5 | 3
2 | 2 | 5
2 | 3 | 5
would ideally result in
id | rating_list
1 | [5,4,0,5,0,0,3]
2 | [0,5,5,0,3,0,0]
where the length of the rating_list is the number of distinct items in the data frame. So far I have a dataframe with a list of items and a list of ratings, but I'm not sure if this is even the appropriate intermediate step
id | item_list | rating_list
1 | [1,2,4,7] | [5,4,5,3]
2 | [2,3,5] | [5,5,3]
This will be a huge dataframe so I prefer things that are quicker.
rating_list
should be 6 instead of 7?