python和pandas处理excel(6)

2020-08-29  本文已影响0人  OURPIECE

排序

场景1

import pandas as pd
df = pd.read_excel("E:/test.xlsx",index_col='ID')
df.sort_values(by='字段名', inplace=True,ascending=False) //by:字段名,ascending默认从小到大
// 多条件排序,按by数组从左到右的条件规则先后排序
df.sort_values(by=['字段名1','字段名2'], inplace=True,ascending=[True, False]) //by  和 ascending值保持对应关系
上一篇 下一篇

猜你喜欢

热点阅读