#--引入数据
import pandas as pd
import numpy as np
df = pd.DataFrame(data=np.random.rand(30).reshape((6,5)),columns=['b','a','d','c','e'])

#--自动title排序
df = df.sort_index(axis=1)

#--自定义title顺序
df = df[['e','a','c','d','b']]

#--根据值排序
df = df.sort_values(by=['a','b'],ascending=[False,True])

网友评论