title: how to create a group ID based on 5 minutes interval in pandas timeseries?
body: <p>I have a timeseries dataframe  <code>df</code> looks like this (the time seris happen within same day, but across different hours:</p>
  
  <pre><code>                                id               val 
   time                    
  2014-04-03 16:01:53             23              14389      
  2014-04-03 16:01:54             28              14391             
  2014-04-03 16:05:55             24              14393             
  2014-04-03 16:06:25             23              14395             
  2014-04-03 16:07:01             23              14395             
  2014-04-03 16:10:09             23              14395             
  2014-04-03 16:10:23             26              14397             
  2014-04-03 16:10:57             26              14397             
  2014-04-03 16:11:10             26              14397              
  </code></pre>
  
  <p>I need to create group every 5 minutes from starting from <code>16:00:00</code>. That is all the rows with in the range <code>16:00:00</code> to <code>16:05:00</code>, its value of the new column <code>period</code> is 1. (the number of rows within each group is irregular, so i can't simply cut the group)</p>
  
  <p>Eventually, the data should look like this:</p>
  
  <pre><code>                                id               val           period 
  time            
  2014-04-03 16:01:53             23              14389             1
  2014-04-03 16:01:54             28              14391             1
  2014-04-03 16:05:55             24              14393             2
  2014-04-03 16:06:25             23              14395             2
  2014-04-03 16:07:01             23              14395             2
  2014-04-03 16:10:09             23              14395             3
  2014-04-03 16:10:23             26              14397             3
  2014-04-03 16:10:57             26              14397             3
  2014-04-03 16:11:10             26              14397             3
  </code></pre>
  
  <p>The purpose is to perform some <code>groupby</code> operation, but the operation I need to do is not included in <code>pd.resample(how=' ')</code> method. So I have to create a <code>period</code> column to identify each group, then do <code>df.groupby('period').apply(myfunc)</code>.</p>
  
  <p>Any help or comments are highly appreciated.</p>
  
  <p>Thanks!</p>