我已经尝试过此代码
result = df1.groupby(["Customer Name","Product Name"])
['Sales'].aggregate(np.sum).reset_index().sort_values('Sales',ascending = False).head(5)
结果
ID Customer Name Product Name Sales
8567 Sean Miller Cisco TelePresence System EX90 Videoconferenci... 22638.480
9165 Tamara Chand Canon imageCLASS 2200 Advanced Copier 17499.950
7725 Raymond Buch Canon imageCLASS 2200 Advanced Copier 13999.960
9487 Tom Ashbrook Canon imageCLASS 2200 Advanced Copier 11199.968
4083 Hunter Lopez Canon imageCLASS 2200 Advanced Copier 10499.970
我不确定如何获得各自销售的前五名产品。