title: Cumsum only on toggle in pandas python
body: <p>I have the following dataframe:</p>
  
  <pre><code>             pct_day    True_False
  Date        
  2018-01-02  NaN False
  2018-01-03  0.006399    False
  2018-01-04  0.004029    False
  2018-01-05  0.007034    False
  2018-01-08  0.001662    False
  ... ... ...
  2020-01-23  0.001141    True
  2020-01-24  -0.009042   True
  2020-01-27  -0.015731   True
  2020-01-28  0.010054    True
  2020-01-29  -0.000867   False
  522 rows × 2 columns
  </code></pre>
  
  <p>What i want to do is <code>cumsum()</code> on <code>False</code> and restart when it toggles to <code>True</code>. I want the cumulative sum to be only on consecutive True or False. </p>
  
  <p>A similar question was asked here:
  <a href="https://stackoverflow.com/questions/40802800/how-to-groupby-consecutive-values-in-pandas-dataframe">How to groupby consecutive values in pandas DataFrame</a></p>
  
  <pre><code>for row in data3:
      if data3.True_False == data3.True_False.shift():
          print(data3.pct_day.cumsum())
  </code></pre>
  
  <p>But this produces an error:</p>
  
  <blockquote>
    <p>ValueError: The truth value of a Series is ambiguous. Use a.empty,
    a.bool(), a.item(), a.any() or a.all().</p>
  </blockquote>
  
  <p>How can i get the iteration to continue only if the condition is true?</p>