Reputation: 43
I need helo creating the format transformation:
I have created pd.wide_to_long but I cannot find an example identical to mine?
Can you help?
Upvotes: 1
Views: 26
Reputation: 30930
Use:
df.set_index(['City','Var']).rename_axis(columns='Year').stack().unstack('Var')
Upvotes: 1