How do you “pivot” using conditions, aggregation, and concatenation in Pandas?
问题 I have a dataframe in a format such as the following: Index Name Fruit Quantity 0 John Apple Red 10 1 John Apple Green 5 2 John Orange Cali 12 3 Jane Apple Red 10 4 Jane Apple Green 5 5 Jane Orange Cali 18 6 Jane Orange Spain 2 I need to turn it into a dataframe such as this: Index Name All Fruits Apples Total Oranges Total 0 John Apple Red, Apple Green, Orange Cali 15 12 1 Jane Apple Red, Apple Green, Orange Cali, Orange Spain 15 20 Question is how do I do this? I have looked at the groupby