I am a novice in Python pandas.
I would like to do a particular aggregation / grouping / cross-tab but I know so little of the terminology that I do not even know how to look this up.
But here is what I would like.
Say I have a table like this:
Bob, Oranges, 5 Bob, Apples, 10 Bob, Bananas, 12 Tim, Oranges, 3 Tim, Apples, 20 Tim, Bananas, 5
I would like to groupby fruit to find the total for each type of fruit. But produce another field containing a string which has the details sorted by their value in another column.
So I would like an output something like this:
Oranges, 8, "Bob(5), Tim(3)" Apples, 30, "Tim(20), Bob(10)" Bananas, 17, "Bob(12), Tim(5)"
Where the string aggregates the values from the names column in a list sorted by the associated numeric value.
I know that there isn't something out of the box to do this, but what is this kind of operation or aggregation or pivoting (where you take one of the columns and turn it to be "horizontal" if that makes any sense) actually called?
How would I go about implementing it in pandas functions?