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

前端 未结 7 1167
走了就别回头了
走了就别回头了 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:10

    If you are writing this code as a script file then you will have to write it like this:

    df = df.sort(['c1','c2'], ascending=[False,True])
    

提交回复
热议问题