How to sort pandas data frame using values from several columns?

前端 未结 7 1126
走了就别回头了
走了就别回头了 2020-12-02 09:33

I have the following data frame:

df = pandas.DataFrame([{\'c1\':3,\'c2\':10},{\'c1\':2, \'c2\':30},{\'c1\':1,\'c2\':20},{\'c1\':2,\'c2\':15},{\'c1\':2,\'c2\'         


        
相关标签:
7条回答
  • 2020-12-02 10:33

    Note : Everything up here is correct,just replace sort --> sort_values() So, it becomes:

     import pandas as pd
     df = pd.read_csv('data.csv')
     df.sort_values(ascending=False,inplace=True)
    

    Refer to the official website here.

    0 讨论(0)
提交回复
热议问题