Multi-Index Sorting in Pandas

后端 未结 5 1773
暖寄归人
暖寄归人 2020-12-13 02:58

I have a multi-index DataFrame created via a groupby operation. I\'m trying to do a compound sort using several levels of the index, but I can\'t seem to find a sort functi

5条回答
  •  甜味超标
    2020-12-13 03:28

    If you are not concerned about conserving the index (I often prefer an arbitrary integer index) you can just use the following one-liner:

    grouped.reset_index().sort(["Manufacturer","Product Launch Date"])
    

提交回复
热议问题