Merge columns in Multiindex dataframe

I have multiindex dataframe which is looks like: dataframe

How can i make it like this: desired output

Code:

df_1 = df[['Code', 'SKU', 'Sales7days', 'Day', 'Discount']] pivoted = df_1.pivot_table(index='Code', columns='Day', values=['Sales7days', 'Discount']) pivoted = pivoted.swaplevel(1,0, axis=1) 
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.