Skip to content Skip to sidebar Skip to footer

Pandas Sort MultiIndex Pivot Table

Given the following pivot table: import pandas as pd import numpy as np df = pd.DataFrame( {'YYYYMM':[201603,201503,201403,201303,201603,201503,201403,201303], 'Co

Solution 1:

Use sort_values

t.sort_values(('Count', 2016))

the tuple ('Count', 2016) is the name of the column you want to sort by.

looks like:

       Count               
YYYYMM  2013 2014 2015 2016
Group                      
B          9    8    7    4
A          7    2    6    5

Post a Comment for "Pandas Sort MultiIndex Pivot Table"