How to sort a Pandas DataFrame according to multiple criteria?

后端 未结 5 657
独厮守ぢ
独厮守ぢ 2020-12-24 02:21

I have the following DataFrame containing song names, their peak chart positions and the number of weeks they spent at position no 1:

                                


        
5条回答
  •  北荒
    北荒 (楼主)
    2020-12-24 02:40

    df.sort(['Peak', 'Weeks'], ascending=[True, False], inplace=True)
    

    If you want the sorted result for future use, inplace=True is required.

提交回复
热议问题