Reputation: 1189
I have an int64 index representing year values that I want to treat as a timestamp index:
df.index
Int64Index([2001,2002,2003], dtype='int64')
How do I convert the index to a datetime timestamp in pandas?
Upvotes: 15
Views: 18299
Reputation: 19104
import pandas as pd
df.index = pd.to_datetime(df.index, format='%Y')
Upvotes: 32