Merge 2 different sized dfs, taking missing values from closest date

I've got two fairly large dataframes of mismatched sizes (and times) of the following structure(s):

df1:

Date       Value
    2018-04-02  1.8
    2018-04-03  1.82
    2018-04-04  1.84
    2018-04-05  1.75
    2018-04-06  1.9

df2:


    Date        Value
    2018-01-01   1.3
    2018-01-02   1.3
    2018-01-04   1.4
    2018-01-05   1.6

What I'd like to do is combine those dataframes together, assuming that the value for missing values is the value closest to the missing date. So for example, the missing value for df1 on 2018-01-01 would be 1.8, while the missing value for df2 on 2018-04-03 would be 1.3. Once the dataframes are combined, I'd like to create a column that minuses the value of df2 on the day from df1.
Does anyone know how to do this? Any assistance greatly appreciated.

while the missing value for df2 on 2018-04-03 would be 1.3.

would it be 1.6 because 2018-01-05 is closer to 2018-04-03 than either 2018-01-01 or 2018-01-02 ?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.