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.