johnson
johnson

Reputation: 429

How to get back index to dataframe as a column?

I want to get back my current index variable as a column variable. Is it possible?I tried using df.reset_index() but it did not work.Please click the link to view current version of fataframe

Ex:Please Click here to view the current data frame. I want back "Date" as column variable

Upvotes: 0

Views: 279

Answers (1)

n_estrada
n_estrada

Reputation: 86

you could use

df['new_column'] = df.index

It will copy the index as is, so if it's a datetime index then the new column will be a datetime column as well.

Upvotes: 1

Related Questions