title: How to reset cumsum after change in sign of values?
body: <pre><code>In [46]: d = np.random.randn(10, 1) * 2
  
  In [47]: df = pd.DataFrame(d.astype(int), columns=['data'])
  </code></pre>
  
  <p>I am trying to create a cumsum column where it should reset after a sign change in data column, like this</p>
  
  <pre><code>   data  custom_cumsum
  0    -2  -2
  1    -1  -3 
  2     1   1
  3    -3  -3
  4    -1  -4
  5     2   2 
  6     0   2 
  7     3   5 
  8    -1  -1 
  9    -2  -3 
  </code></pre>
  
  <p>I am able to achieve this with <code>df.iterrows()</code>. I am trying to avoid iterrows and do it with vector operations. There are couple of questions on <a href="https://stackoverflow.com/q/29421356/2698552">resetting</a> <a href="https://stackoverflow.com/q/18196811/2698552">cumsum</a> when there is NaN. I am not able to achieve this cumsum with those solutions. </p>