title: How to identify approximately (threshold defined) continuous non null data using pandas?
body: <p>I would like to extract rainfall events from a rainfall time serie while allowing X dry hours (as a parameter) inside the same event. So, by rainfall event, I mean approximately continuous rainfall (RF > 0) with maximum X consecutive dry hours (RF = 0) inside.</p>
  
  <p>I actually don't want to do it the hard way with iterators and increments and I look for pandas or numpy/scipy tools that can be a relief.</p>
  
  <p>Here is a sample of my dataframe. <code>RF</code> is raw rainfall and <code>RFfill</code> is RF.interpolate() to fill nodata. <code>evtId</code>is field created to store events unique id's. </p>
  
  <pre><code>                    TS   RF  RFfill  evtId
  0  1997-11-27 14:00:00  0.3     0.3    NaN
  1  1997-11-27 15:00:00  1.1     1.1    NaN
  2  1997-11-27 16:00:00  0.2     0.2    NaN
  3  1997-11-27 17:00:00  0.0     0.0    NaN
  4  1997-11-27 18:00:00  0.0     0.0    NaN
  5  1997-11-27 19:00:00  1.1     1.1    NaN
  6  1997-11-27 20:00:00  0.6     0.6    NaN
  7  1997-11-27 21:00:00  0.0     0.0    NaN
  8  1997-11-27 22:00:00  0.0     0.0    NaN
  9  1997-11-27 23:00:00  0.0     0.0    NaN
  10 1997-11-28 00:00:00  0.0     0.0    NaN
  11 1997-11-28 01:00:00  0.0     0.0    NaN
  12 1997-11-28 02:00:00  0.0     0.0    NaN
  13 1997-11-28 03:00:00  0.0     0.0    NaN
  14 1997-11-28 04:00:00  0.0     0.0    NaN
  15 1997-11-28 05:00:00  0.0     0.0    NaN
  16 1997-11-28 06:00:00  0.0     0.0    NaN
  17 1997-11-28 07:00:00  0.0     0.0    NaN
  18 1997-11-28 08:00:00  0.0     0.0    NaN
  19 1997-11-28 09:00:00  0.8     0.8    NaN
  20 1997-11-28 10:00:00  1.1     1.1    NaN
  21 1997-11-28 11:00:00  2.3     2.3    NaN
  22 1997-11-28 12:00:00  1.4     1.4    NaN
  23 1997-11-28 13:00:00  0.4     0.4    NaN
  24 1997-11-28 14:00:00  0.2     0.2    NaN
  25 1997-11-28 15:00:00  0.0     0.0    NaN
  26 1997-11-28 16:00:00  0.0     0.0    NaN
  27 1997-11-28 17:00:00  0.0     0.0    NaN
  28 1997-11-28 18:00:00  0.0     0.0    NaN
  29 1997-11-28 19:00:00  0.0     0.0    NaN
  30 1997-11-28 20:00:00  0.0     0.0    NaN
  </code></pre>
  
  <p>Here is the expected output with 5 hours of allowed dry hours :</p>
  
  <pre><code>                    TS   RF  RFfill  evtId
  0  1997-11-27 14:00:00  0.3     0.3    0
  1  1997-11-27 15:00:00  1.1     1.1    0
  2  1997-11-27 16:00:00  0.2     0.2    0
  3  1997-11-27 17:00:00  0.0     0.0    0
  4  1997-11-27 18:00:00  0.0     0.0    0
  5  1997-11-27 19:00:00  1.1     1.1    0
  6  1997-11-27 20:00:00  0.6     0.6    0
  7  1997-11-27 21:00:00  0.0     0.0    NaN
  8  1997-11-27 22:00:00  0.0     0.0    NaN
  9  1997-11-27 23:00:00  0.0     0.0    NaN
  10 1997-11-28 00:00:00  0.0     0.0    NaN
  11 1997-11-28 01:00:00  0.0     0.0    NaN
  12 1997-11-28 02:00:00  0.0     0.0    NaN
  13 1997-11-28 03:00:00  0.0     0.0    NaN
  14 1997-11-28 04:00:00  0.0     0.0    NaN
  15 1997-11-28 05:00:00  0.0     0.0    NaN
  16 1997-11-28 06:00:00  0.0     0.0    NaN
  17 1997-11-28 07:00:00  0.0     0.0    NaN
  18 1997-11-28 08:00:00  0.0     0.0    NaN
  19 1997-11-28 09:00:00  0.8     0.8    1
  20 1997-11-28 10:00:00  1.1     1.1    1
  21 1997-11-28 11:00:00  2.3     2.3    1
  22 1997-11-28 12:00:00  1.4     1.4    1
  23 1997-11-28 13:00:00  0.4     0.4    1
  24 1997-11-28 14:00:00  0.2     0.2    1
  25 1997-11-28 15:00:00  0.0     0.0    NaN
  26 1997-11-28 16:00:00  0.0     0.0    NaN
  27 1997-11-28 17:00:00  0.0     0.0    NaN
  28 1997-11-28 18:00:00  0.0     0.0    NaN
  29 1997-11-28 19:00:00  0.0     0.0    NaN
  30 1997-11-28 20:00:00  0.0     0.0    NaN
  </code></pre>
  
  <p>Any ideas that could help me to achieve this ?</p>