0

I have a dataframe which is like as shown below

enter image description here

Though I know the column names are 'FR', 'ig' and 'te' with the help of below command.

dataFramesDict['Tri'].columns

enter image description here

What does name = 'level_1' mean here? Moreover, I also don't see subject_ID in the columns or index list. What is subject_ID here?

How do I get the output to be like as shown below

enter image description here

I tried the below code to rename 'level_1' to 'subject_ID' but it doesn't work

dataFramesDict['Tri'].index = dataFramesDict['Tri'].index.rename('subject_ID')

Please note that the data is just a sample data. I am only interested in changing the first column name and dropping that 'level_1'. Nothing to do with data

I am unable to create dataframe of this type through sample code. The above shown dataframe is a result of another complex code. So, I have provided a screenshot of dataframe

The Great
  • 6,010
  • 5
  • 18
  • 62

1 Answers1

3

Try this

df.columns.name= ''
df.reset_index(inplace=True)
tawab_shakeel
  • 3,541
  • 8
  • 25