Dataframe set_index not set

I have a dataframe and am trying to set the index to the "Timestamp" column. Currently, an index is just a line number. Timestamp format example: 2015-09-03 16:35:00

I tried to set the index:

df.set_index('Timestamp') 

I am not getting an error, but when I print a DataFrame, the index is still the line number. How can I use Timestamp as an index?

+5
source share
1 answer

You need to either specify inplace=True , or assign the result to a variable. Try:

 df.set_index('Timestamp', inplace=True, drop=True) 
+7
source

Source: https://habr.com/ru/post/1264144/


All Articles