Home > other >  How append a new index to dataframe?
How append a new index to dataframe?

Time:04-26

I have a dataframe like bellow, and I want to append t as a new row data to the d1, but it failed ? enter image description here

CodePudding user response:

You can add the row directly:

df1.loc['new_index'] = t

CodePudding user response:

Use:

df.append(df.iloc[1]/df.iloc[0], ignore_index=True)

Demonstration, df:

enter image description here

after appending:

enter image description here

  • Related