1sorted = df.sort_values('column-to-sort-on', ascending=False)
2#or
3df.sort_values('name', inplace=True)
1# Basic syntax:
2import pandas as pd
3df.sort_values(by=['col1'])
4
5# Note, this does not sort in place unless you add inplace=True
6# Note, add ascending=False if you want to sort in decreasing order
7# Note, to sort by more than one column, add other column names to the
8# list like by=['col1', 'col2']
1#old df columns
2df.columns
3Index(['A', 'B', 'C', 'D'],dtype='***')
4#new column format that we want to rearange
5new_col = ['D','C','B','A'] #list of column name in order that we want
6
7df = df[new_col]
8df.columns
9Index(['D', 'C', 'B', 'A'],dtype='***')
10#new column order