Reputation: 23
I am new to python. I have a dataframe in below format
I want to pivot it to below format
How can i do this?
Upvotes: 2
Views: 51
Reputation: 71580
Try using df.melt
:
print(df.melt(id_vars='Name'))
If pandas version is under 0.20.0, try pd.melt
:
print(pd.melt(df, id_vars='Name'))
Upvotes: 1