DF1 is the test data for the DATAFRAME structure:
The DF1 data is read from the TEST.XLSX document, using the sample code as follows:
#-*-Coding:utf-8-*-import Tushare as Tsimport pandas as Pddf = Pd.read_excel (' test.xlsx ') df1 = Df.head (Ten) #dataframe按索引 In ascending order, the default is ascending #print df1.sort_index () #dataframe按索引降序排列 #print df1.sort_index (ascending=false) #第一行按升序排序, which is ascending by default #print Df1.sort_index (Axis=1) #第一行按降序排序 #print df1.sort_index (Axis=1, Ascending=false) #以amount这一列的值进行排序, default from small to large #print Df1.sort_values (by= ' amount ') #以amount这一列的值进行排序, from large to small #print df1.sort_values (by= ' Amount ', Ascending=false) #以多列排序, The values of the amount and price columns are sorted from large to small #print df1.sort_values (by=[' Amount ', ' price '], Ascending=false)
Sorting of Pandas Library Dataframe