title: How to create a rolling time window with offset in Pandas
body: <p>I want to apply some statistics on records within a time window with an offset. My data looks something like this:</p>
  
  <pre><code>                             lon        lat  stat  ...   speed  course  head
  ts                                                 ...                      
  2016-09-30 22:00:33.272  5.41463  53.173161    15  ...     0.0     0.0   511
  2016-09-30 22:01:42.879  5.41459  53.173180    15  ...     0.0     0.0   511
  2016-09-30 22:02:42.879  5.41461  53.173161    15  ...     0.0     0.0   511
  2016-09-30 22:03:44.051  5.41464  53.173168    15  ...     0.0     0.0   511
  2016-09-30 22:04:53.013  5.41462  53.173141    15  ...     0.0     0.0   511
  
  [5 rows x 7 columns]
  </code></pre>
  
  <p>I need the records within time windows of 600 seconds, with steps of 300 seconds. For example, these windows:</p>
  
  <pre><code>start                     end
  2016-09-30 22:00:00.000   2016-09-30 22:10:00.000
  2016-09-30 22:05:00.000   2016-09-30 22:15:00.000
  2016-09-30 22:10:00.000   2016-09-30 22:20:00.000
  </code></pre>
  
  <p>I have looked at Pandas <a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.rolling.html" rel="nofollow noreferrer">rolling</a> to do this. But it seems like it does not have the option to add the offset which I described above. Am I overlooking something, or should I create a custom function for this?</p>