I have a dataframe that looks like this:
userid itemid score
1 5 4
2 3 10
1 5 20
2 3 30
I want to convert this dataframe to:
userid itemid score
1 5 22
2 3 20
I am planning to do this using 2 for loops. However, I wonder if there is any recommended approach for achieving this task?
groupby
does not seem to work since it does not have
average
function. Any help?