Panda group dataframe based on datetime type into different period ignoring date part
<p>I want to group the rows into groups, based on variable time interval.
However, when doing grouping, I want to ignore the date part, only group based on the time date. </p>

<p>Say I want to group every 5 minutes.</p>

<pre><code>       timestampe            val
0  2016-08-11 11:03:00        0.1
1  2016-08-13 11:06:00        0.3
2  2016-08-09 11:04:00        0.5
3  2016-08-05 11:35:00        0.7
4  2016-08-19 11:09:00        0.8
5  2016-08-21 12:37:00        0.9

        into 

       timestampe             val
0  2016-08-11 11:03:00        0.1
2  2016-08-09 11:04:00        0.5

       timestampe             val
1  2016-08-13 11:06:00        0.3
4  2016-08-19 11:09:00        0.8

       timestampe             val
3  2016-08-05 11:35:00        0.7
       timestampe             val
5  2016-08-21 12:37:00        0.9
</code></pre>

<p>Notice as long as the time is within the same 5 minutes interval, the rows are grouped, regardless of the date.</p>

<p>This is assuming you split the day up into 5 minute windows</p>

<pre><code>df.groupby(df.timestampe.dt.hour.mul(60) \
             .add(df.timestampe.dt.minute) // 5) \
  .apply(pd.DataFrame.reset_index)
</code></pre>

<p><a href="http://i.stack.imgur.com/7Y76B.png" rel="nofollow"><img src="http://i.stack.imgur.com/7Y76B.png" alt="enter image description here"></a></p>

<hr>

<pre><code>for name, group in df.groupby(df.timestampe.dt.hour.mul(60).add(df.timestampe.dt.minute) // 5):
    print name
    print group
    print

132
           timestampe  val
0 2016-08-11 11:03:00  0.1
2 2016-08-09 11:04:00  0.5

133
           timestampe  val
1 2016-08-13 11:06:00  0.3
4 2016-08-19 11:09:00  0.8

139
           timestampe  val
3 2016-08-05 11:35:00  0.7

151
           timestampe  val
5 2016-08-21 12:37:00  0.9
</code></pre>

python datetime pandas numpy scipy