I have data that I need to aggregate for per column and then per column again. What I need is total spend per product category for each unique customer. Multiindex should do this. Problem is that I am new to Pandas, and I don't understand multiindexing.
I have data structured like this:
Customer Products Amount
1 001 Toys 5
2 002 Toys 6
3 002 Cars 7
4 001 Toys 2
5 001 Cars 9
I need it like this:
Customers Products Sum of ammount
001 Toys 7
Cars 9
002 Toys 6
Cars 7
Later I need to transform it so that I can get total spend per product category, per customer.
Customer Toys Cars
001 7 9
002 6 7
I have been playing around with the code, but I am stuck. Have been reading up, but not finding exactly what I am looking for.
Aucun commentaire:
Enregistrer un commentaire