简体   繁体   中英

How to get column values from another dataframe with a different datetime index

I have a trading dataframes with different intervals, eg. 1 minute and 5 minute. I wish to copy the calculated value from the slower 5min to the 1min dataframe.

eg the 1min is thus: 在此处输入图像描述

I wish to add a forecast_5m or something to that dataframe which has the previous 5min value of the forecast column from the 5min dataframe. Since it is 5min to 1 the sequence of the 1min should then have 5 duplicate values in the column from the previous 5min value found in the other dataframe.

In the picture it is 14:53:00 so it should get the 14:50:00 value, etc. The same for all the minutes to 14:54. I'm getting confused with how to select the last time available as most solutions are about time ranges etc, and not finding the latest closest available in another dataframe.

Did you try to resample the dataframe to one minute intervals with any aggregate?

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