user308827
user308827

Reputation: 21971

reorder column in pandas pivot table

How do I reorder the LandUse column in this dataframe:

Region                       North         South
LandUse          Year                           
Corn             2005  149102.3744  2078875.0976
                 2010  201977.2160  2303998.5024
Developed        2005    1248.4416    10225.5552
                 2010     707.4816     7619.8528
Forests/Wetlands 2005   26511.4304    69629.8624
                 2010   23433.7600    48124.4288
Open Lands       2005  232290.1056   271714.9568
                 2010   45845.8112   131696.3200
Other Ag         2005  125527.1808   638010.4192
                 2010  257439.8848   635332.9024
Soybeans         2005   50799.1232  1791342.1568
                 2010   66271.2064  1811186.4512

Currently, 'LandUse' is organized alphabetically. I want it to be in following order:

lst = ['Open Lands','Forests/Wetlands','Developed','Corn','Soybeans','Other Ag']

Upvotes: 0

Views: 573

Answers (1)

Karthik V
Karthik V

Reputation: 1897

You could do df = df.loc[lst] to reorder the index.

Upvotes: 1

Related Questions