title: How to print out the last n minutes of rows before a specific row in pandas?
body: <p>I have a df with incidents and warnings and I would like to store the last 10 minutes of data that came before each incident in another df called &quot;df1&quot;. I have added a boolean column to identify incidents in the df but I need a way to loop through the whole df and store the rows that occurred 10 minutes before each incident along with the incident itself.</p>
  <p>for ex:</p>
  <pre><code>A                B                   Incident
  warning      2018-11-01 01:37:12        F
  warning      2018-11-01 01:37:41        F
  warning      2018-10-31 01:37:48        F
  warning      2018-10-30 01:40:31        F
  warning      2018-10-29 01:43:41        F
  warning      2018-10-28 01:45:51        F
  incident     2018-10-27 01:47:41        T
  </code></pre>
  <p>In this case i would need to store</p>
  <pre><code>warning      2018-11-01 01:37:41        F
  warning      2018-10-31 01:37:48        F
  warning      2018-10-30 01:40:31        F
  warning      2018-10-29 01:43:41        F
  warning      2018-10-28 01:45:51        F
  incident     2018-10-27 01:47:41        T
  </code></pre>
  <p>If there is another incident contained within the last 10 minutes of the first incident, I would like to use all the data before the second incident occurred. i.e., if no incident in last 10 mins, append df A, else append df B to df1.</p>