import pandas as pd
books = pd.read_excel('D:/output.xlsx', index_col='idx')
# 按照SinglePrice排序
books.sort_values(by='SinglePrice', inplace=True, ascending=False)
# 按照TotalMoney排序
books.sort_values(by='TotalMoney', inplace=True, ascending=False)
# 先按照SinglePrice正序排序, 再按照TotalMoney倒序排序
books.sort_values(by=['SinglePrice','TotalMoney'], inplace=True, ascending=[True, False])
print(books)
视频链接:https://www.bilibili.com/video/av88814463?p=7
来源:oschina
链接:https://my.oschina.net/ski/blog/3179450