Shankar Panda
Shankar Panda

Reputation: 822

How to Make the first index column as null?

How to rename the "key" to null from the last DF result?

enter image description here

Upvotes: 3

Views: 57

Answers (2)

Mikolaj
Mikolaj

Reputation: 356

I would try:

df1 = df.rename(columns = {"" : "Metric", "seg1", ""seg2})

Of course, you change "df1" to fit your final result.

Upvotes: 0

ansev
ansev

Reputation: 30920

Use DataFrame.rename_axis():

df.pivot(index='Metric', columns='key', values='value').reset_index()\
  .rename_axis(columns=None)

Upvotes: 1

Related Questions