Python 对组内多索引数据帧中的聚合列进行排序

Python 对组内多索引数据帧中的聚合列进行排序,python,pandas,multi-index,Python,Pandas,Multi Index,受数据启发,我们有以下系列/数据框架 df=data.groupby([“制造商”、“产品名称”、“产品发布数据”).sum(“总计”) 在保留组的同时,我们如何在总数之后进行排序,即以: total Manufacturer Product Name Product Launch Date Apple iPad 2010-04-03

受数据启发,我们有以下系列/数据框架

df=data.groupby([“制造商”、“产品名称”、“产品发布数据”).sum(“总计”)

在保留组的同时,我们如何在
总数之后进行排序,即以:

                                                 total
Manufacturer Product Name Product Launch Date       
Apple        iPad         2010-04-03              30
             iPod         2001-10-23              34
Samsung      Galaxy Tab   2010-09-02              22
             Galaxy       2009-04-27              24


在最新版本中,可以按级别和列名称一起进行排序,因此这里的工作:

df = df.sort_values(['Manufacturer','total'])
print (df)
                                               total
Manufacturer Product Name Product Launch Date       
Apple        iPad         2010-04-03              30
             iPod         2001-10-23              34
Samsung      Galaxy Tab   2010-09-02              22
             Galaxy       2009-04-27              24

在最新版本中,可以按级别和列名称一起进行排序,因此这里的工作:

df = df.sort_values(['Manufacturer','total'])
print (df)
                                               total
Manufacturer Product Name Product Launch Date       
Apple        iPad         2010-04-03              30
             iPod         2001-10-23              34
Samsung      Galaxy Tab   2010-09-02              22
             Galaxy       2009-04-27              24

谢谢为什么我没有看到这一点?我已经在文档中担任主角这么长时间了,谢谢!为什么我没有看到这一点?我已经在文档中担任主角这么长时间了