how to sort pandas dataframe from one column

后端 未结 6 1314
感情败类
感情败类 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:03

    I tried the solutions above and I do not achieve results, so I found a different solution that works for me. The ascending=False is to order the dataframe in descending order, by default it is True. I am using python 3.6.6 and pandas 0.23.4 versions.

    final_df = df.sort_values(by=['2'], ascending=False)
    

    You can see more details in pandas documentation here.

提交回复
热议问题