'Changing column order in python pandas using pivot table pd
I would love to change the order of my pivot table using pd (pandas)
Current layout
Code:
pd.pivot_table(df.loc[filt],
index=['region','brand'],
values['salesrevenue','contributionmargin','variablecost'])
The code is displaying contribution margin, salesrevenue and variablecost.
I would like to have this layout 'salesrevenue','contributionmargin','variablecost', is there a way to change this?
pd.pivot_table(df.loc[filt],
index=['region','brand'],
values=['salesrevenue','contributionmargin','variablecost'])
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|