Pandas, check if timestamp value exists in resampled 30 min time bin of datetimeindex <p>I have created a resampled data frame (DF1) in pandas with a <code>datetimeindex</code>. I have a separate dataframe (DF2) with a <code>datetimeindex</code> and <code>time</code> column. If an instance of <code>time</code> from DF2 falls within the 30 min bins of <code>datetimeindex</code> in DF1. I want to mark each instance of <code>time</code> in DF2 with the appropriate <code>speed</code> from the 30 min bin in DF1. </p> <p>DF1</p> <pre><code> boat_id speed time 2015-01-13 09:00:00 28.000000 0.000000 2015-01-13 09:30:00 28.000000 0.723503 2015-01-13 10:00:00 28.000000 2.239399 </code></pre> <p>DF2</p> <pre><code> id boat_id time state time 2015-01-18 16:09:03 319437 28 2015-01-18 16:09:03 2 2015-01-18 16:18:43 319451 28 2015-01-18 16:18:43 0 2015-03-01 09:39:51 507108 31 2015-03-01 09:39:51 1 2015-03-01 09:40:58 507109 31 2015-03-01 09:40:58 0 </code></pre> <p>Desired Result</p> <pre><code> id boat_id time state speed time 2015-01-18 16:09:03 319437 28 2015-01-18 16:09:03 2 nan 2015-01-18 16:18:43 319451 28 2015-01-18 16:18:43 0 nan 2015-03-01 09:39:51 507108 31 2015-03-01 09:39:51 1 2.239399 2015-03-01 09:40:58 507109 31 2015-03-01 09:40:58 0 2.239399 </code></pre> <p>I created this script to try and do this but I think it's failing because <code>datetimeindex</code> of DF1 is immutable and so my <code>timedelta</code> request doesn't create a start point for the chunk. One thought I had was if it would be possible to copy the <code>datetimeindex</code> of DF1 into a new column where the objects are mutable but I haven't managed it yet so am not 100% sure of the logic. I'm happy to tinker but at the moment i've been stalled for a while so was hoping someone else might have a few ideas. Thanks in advance.</p> <pre><code>for row in DF1.iterrows(): for dfrow in DF2.iterrows(): if dfrow[0] &gt; row[0] - dt.timedelta(minutes=30) and dfrow[0] &lt; row[0]: df['test'] = row[1] </code></pre>