Reputation: 822
How to rename the "key" to null from the last DF result?
Upvotes: 3
Views: 57
Reputation: 356
I would try:
df1 = df.rename(columns = {"" : "Metric", "seg1", ""seg2})
Of course, you change "df1" to fit your final result.
Upvotes: 0
Reputation: 30920
df.pivot(index='Metric', columns='key', values='value').reset_index()\
.rename_axis(columns=None)
Upvotes: 1