0

Sorry for the poor title, I am not sure how to best describe my issue in one line

I have a dataframe df1 with index:

[2014-01-02 10:00:02.644000, ..., 2014-01-02 15:59:58.630000] Length: 26761, Freq: None, Timezone: None

My df1 column price contains some values like 40,38, etc.

My df1 looks like this:

Timestamp                   price1                                                   
2014-01-02 10:00:02.120000  38
2014-01-02 10:00:03.213000  40
2014-01-02 10:00:06.648000  39 
2014-01-02 10:00:02.699320  50
...

I have another DataFrame, df2

Timestamp                   price2                                                   
2014-01-02 10:00:06.879000  39
2014-01-02 10:00:07.457200  41
2014-01-02 10:00:10.625450  35 
2014-01-02 10:00:12.674320  47
...

My objective is to create another variable, price2 in df1 that locates the value of price2 5 minutes after each timestamps in df1. For instance, if we look at the first row in df1, price2 will be equal to the value of price2 at 10:00:07.120000 in df2. BUT, I don't have a price price2 in df2 at that specified time. I will have to extrapolate... what's the best way to do this?

Plug4
  • 3,838
  • 9
  • 51
  • 79

1 Answers1

0

I got my answer here. This methodology helps me to find the closest match based on time. I couldn't ask for something better!

Community
  • 1
  • 1
Plug4
  • 3,838
  • 9
  • 51
  • 79