Merge two dataframes based on closest/nearest datetime

Viewed 35

I have two data sets, both containing 'id' and 'datetime'.

Samples look like this :

Merging algorithm has two conditions.

  1. I want to match left rows to one of the right row which is the nearest.

  2. It should only match if the right datetime is a later datetime than the left datetime.

How can I merge these two dataframes?

0 Answers
Related