title: Pattern identification in a dataset using python
body: <p>I have a dataframe that looks something like this:</p>
  
  <pre><code>empl_ID day_1  day_2  day_3  day_4  day_5  day_6  day_7  day_8  day_9  day_10
   1        1      1      1      1      1      1      0      1      1      1
   2        0      0      1      1      1      1      1      1      1      0
   3        0      1      0      0      1      1      1      1      1      1
   4        1      0      1      0      1      1      1      0      1      0
   5        1      0      0      1      1      1      1      1      1      1
   6        0      0      0      0      1      1      1      1      1      1
  </code></pre>
  
  <p>As we can see we have 6 employees and index 1 indicates their presence for that day. I want to write a code using Python such that I can trace 2 continuous absences i.e. pattern 0 ,0 for day i, day i+1 in a time-frame of 6 days right from the person begins his employment. </p>
  
  <p>For example, employee 1 begins his work at day_1 column, which is his first appearance of 1. So, from columns day_1 to day_6 if we do not observe any continuous 0, 0 that record should be labeled as '0'. Same would be the case for employee 2 (cols: day_3 to day_8), employee 4 (cols: day_1 to day_6) and employee 6 (cols: day_5 to day_10) and they will be labeled as '0'.</p>
  
  <p>However, for employee 3 (cols: day_2 to day_7), employee 6 (cols: day_5 to day_10) they contain a 0, 0 pattern right from their first presence of 1 within the respective time-frame and thus will be labeled as '1'.</p>
  
  <p>It would be really helpful if someone could help me in formulating a code to achieve the above objective. Thanks in advance! </p>
  
  <p>The result should look something like this:</p>
  
  <pre><code>empl_ID day_1 day_2 day_3 day_4 day_5 day_6 day_7 day_8 day_9 day_10 label
   1        1     1     1     1     1     1     0     1     1     1      0
   2        0     0     1     1     1     1     1     1     1     0      0
   3        0     1     0     0     1     1     1     1     1     1      1
   4        1     0     1     0     1     1     1     0     1     0      0
   5        1     0     0     1     1     1     1     1     1     1      1
   6        0     0     0     0     1     1     1     1     1     1      0
  </code></pre>