title: Merge dataframes on nearest datetime / timestamp
body: <p>I have two data frames as follows:</p>
  
  <pre><code>A = pd.DataFrame({"ID":["A", "A", "C" ,"B", "B"], "date":["06/22/2014","07/02/2014","01/01/2015","01/01/1991","08/02/1999"]})
  
  B = pd.DataFrame({"ID":["A", "A", "C" ,"B", "B"], "date":["02/15/2015","06/30/2014","07/02/1999","10/05/1990","06/24/2014"], "value": ["3","5","1","7","8"] })
  </code></pre>
  
  <p>Which look like the following:</p>
  
  <pre><code>&gt;&gt;&gt; A
    ID       date
  0  A 2014-06-22
  1  A 2014-07-02
  2  C 2015-01-01
  3  B 1991-01-01
  4  B 1999-08-02
  
  &gt;&gt;&gt; B
    ID       date value
  0  A 2015-02-15     3
  1  A 2014-06-30     5
  2  C 1999-07-02     1
  3  B 1990-10-05     7
  4  B 2014-06-24     8
  </code></pre>
  
  <p>I want to merge A with the values of B using the nearest date. In this example, none of the dates match, but it could the the case that some do.</p>
  
  <p>The output should be something like this:</p>
  
  <pre><code>&gt;&gt;&gt; C
    ID        date value
  0  A  06/22/2014     8
  1  A  07/02/2014     5
  2  C  01/01/2015     3
  3  B  01/01/1991     7
  4  B  08/02/1999     1
  </code></pre>
  
  <p>It seems to me that there should be a native function in pandas that would allow this. </p>
  
  <p>Note: as similar question has been asked here
  <a href="https://stackoverflow.com/questions/21201618/pandas-merge-match-the-nearest-time-stamp-the-series-of-timestamps">pandas.merge: match the nearest time stamp &gt;= the series of timestamps</a></p>