title: How to get the Toggle flag value and sum of rows between the flag toggle
body: <p>In continuation to my previous <a href="https://stackoverflow.com/questions/57405037/sum-mean-of-the-rows-between-the-flags-toggle-in-dataframe">Question</a> I need some more help.</p>
  
  <p>The dataframe is like</p>
  
  <pre><code>id  power   flag
  0   20      0
  1   25      0
  2   26      1
  3   30      1
  4   18      0
  5   30      0
  6   19      0
  7   21      1
  8   23      0
  </code></pre>
  
  <p>I am trying to have the flag state value along with the toggle count, Means flag toggling state.
  The output should look like this</p>
  
  <pre><code>    Sum of power       flag_state
  0   45 (20 +25)           0
  1   56 (26 + 30)          1
  2   67 (18 +30 +19)       0
  3   21 (21)               1
  4   23 (23)               0
  </code></pre>
  
  <p>Can someone help with this?</p>