title: How to filter rows based on conditioned explained?
body: <p>I have a dataframe sorted by time:</p>
  
  <pre><code>  trID   event  time frameID    
    tID1    d      t1   1
    tID1    s      t2   1
    tID1    d      t3   1     
    tID1    d      t4   2      
    tID1    s      t5   2
    tID1    d      t6   1      
    tID1    s      t7   1      
  </code></pre>
  
  <p>I want to get the sum of the difference of max(time) - min(time)
  each time the frameID changes. For the Dataframe shown above, expected result would be :
      (t3-t1)  + (t7-t6)</p>
  
  <p>There are multiple trIDs, and I need it for each trID</p>