sort pandas dataframe by multiple columns code example
Example 1: sort dataframe by column
df.sort_values(by='col1', ascending=False)
Example 2: sort by two columns in pandas
df.sort_values(['a', 'b'], ascending=[True, False])
Example 3: how to sort dataframe multi columns with multi ascending values
df = df.sort_values(["b", "c"], ascending = (False, True))
Example 4: how to sort the dataframe in python
import pandas as pd
df1=pd.read_csv("registration.csv")
df2=pd.read_csv("payment.csv")
df=pd.merge(df1,df2)
print(df.iloc[:,[0,1,3,4]].to_string(index=False))