title: Pandas Merge on Timestamp in Time Window function
body: <p>My question is regarding two Pandas Dataframes with timestamp information - my left dataframe has a static timestamp, and right dataframe has a time 'window' with a start and end time. I'd like to 'left' merge these dataframes on the basis of the left timestamp falling between the start and end values in the right time window. <code>pd.merge_asof()</code> gets me most of the way there if I was directly comparing two timestamps - however, my time window values and durations vary.</p>
  
  <p>This would be a simplified representation of the columns in question after the goal merge:</p>
  
  <pre><code>timestamp_left       start_right          end_right 
  2014-08-30 18:00:00  2014-08-30 15:00:00  2014-08-31 03:00:00
  2017-03-31 15:30:00  nan                  nan
  </code></pre>
  
  <p>Writing this expression is pretty simple, but I can't seem to find any information in the <code>pandas</code> docs on how to call a function in a merge.</p>
  
  <p>Thanks in advance.</p>
  
  <p>UPDATE:</p>
  
  <p>Found a solution to my problem <a href="https://stackoverflow.com/questions/43593554/merging-two-dataframes-based-on-a-date-between-two-other-dates-without-a-common">here</a>. This cartesian product method and subquery works because of my fairly small dataframe dimensions of [8000x30] and [50x5]. However, for larger datasets, and more complex problems, it would be really useful to merge on the basis of a function call returning boolean instead of testing for equality.</p>