Skip to content

Instantly share code, notes, and snippets.

@ksv-muralidhar
Last active July 29, 2021 10:36
Show Gist options
  • Save ksv-muralidhar/b77e7ff8b301110663d3eea323c76c7c to your computer and use it in GitHub Desktop.
Save ksv-muralidhar/b77e7ff8b301110663d3eea323c76c7c to your computer and use it in GitHub Desktop.
reshape
df.melt()
df_melt = df.melt(id_vars='Particulars')
df_melt
df_melt = df.melt(id_vars='Particulars',
var_name="Year",
value_name="Amount")
df_melt
df_melt.pivot(index="Particulars",
columns="Year",
values="Amount").reset_index()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment