ascending order
import pandas as pd import numpy as np data = (low=2,high=10,size=(5,3)) data2 = (low=2,high=10,size=(5,3)) df1 = (data,columns=["a","b","c"],index=range(5)) df2 = (data2,columns=["a","b","c"],index=range(5)) df1 = df1.sort_values(by=['a','b']) print(df1)
Run results:
descending order
import pandas as pd import numpy as np data = (low=2,high=10,size=(5,3)) data2 = (low=2,high=10,size=(5,3)) df1 = (data,columns=["a","b","c"],index=range(5)) df2 = (data2,columns=["a","b","c"],index=range(5)) df1 = df1.sort_values(by=['a','b'], ascending=[False, False]) print(df1)
Run results:
PS: Descending order by a, then by b
to this article on pandas descending order by a column of the realization of the article is introduced to this, more related pandas column descending content please search for my previous posts or continue to browse the following related articles I hope that you will support me in the future more!