title: Increment count in Pandas dataframe when values change and when time exceeds condition
body: <p>Each time the value of Person changes, reset count to 0. Increment count each time the time is more than 2 from the initial increment.</p>
  <pre><code>Person Time DesiredResult
  B      0    0
  B      2    0
  B      2    0
  B      4    1
  A      0    0
  S      0    0
  S      1    0
  S      2    0
  S      4    1
  S      8    2
  </code></pre>
  <p>code to generate the data frame:</p>
  <pre><code>df = pd.DataFrame({'Person': ['Bob','Bob','Bob','Bob','Alvin','Steve','Steve','Steve','Steve','Steve']
                       ,'Time': [0,2,2,4,0,0,1,2,4,8]
                       ,'DesiredResult': [0,0,0,1,0,0,0,0,1,2]})
  </code></pre>
  <p><a href="https://i.stack.imgur.com/45egh.png" rel="nofollow noreferrer">Image</a> attached at the link below</p>
  <p><img src="https://i.stack.imgur.com/45egh.png" alt="https://i.stack.imgur.com/45egh.png" /></p>