how to sort pandas dataframe from one column

后端 未结 6 1242
感情败类
感情败类 2020-11-22 06:35

I have a data frame like this:

print(df)

        0          1     2
0   354.7      April   4.0
1    55.4     August   8.0
2   176.5   December  12.0
3    9         


        
6条回答
  •  耶瑟儿~
    2020-11-22 07:04

    Here is template of sort_values according to pandas documentation.

    DataFrame.sort_values(by, axis=0,
                              ascending=True,
                              inplace=False,
                              kind='quicksort',
                              na_position='last',
                              ignore_index=False, key=None)[source]
    

    In this case it will be like this.

    df.sort_values(by=['2'])

    API Reference pandas.DataFrame.sort_values

提交回复
热议问题