简体   繁体   中英

How to set the index of a pandas DataFrame to match the index of a datetime series?

I have a pandas DataFrame of a datetime series and a pandas DataFrame with a numbered index:

​How do I set the index of the DataFrame with the numbered index to match the index of the DataFrame with the datetime series?

If same length of both DataFrames :

df1.index = df2.index

Or:

df1= df1.set_index(df2.index)
df.index = pd.PeriodIndex(df.Date, freq='D')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM