Home > database >  How to Make the first index column as null?
How to Make the first index column as null?

Time:03-11

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

enter image description here

CodePudding user response:

Use DataFrame.rename_axis():

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

CodePudding user response:

I would try:

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

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

  • Related