title: Cumsum reset at NaN
body: <p>If I have a <code>pandas.core.series.Series</code> named <code>ts</code> of either 1's or NaN's like this:</p>
  
  <pre><code>3382   NaN
  3381   NaN
  ...
  3369   NaN
  3368   NaN
  ...
  15     1
  10   NaN
  11     1
  12     1
  13     1
  9    NaN
  8    NaN
  7    NaN
  6    NaN
  3    NaN
  4      1
  5      1
  2    NaN
  1    NaN
  0    NaN
  </code></pre>
  
  <p>I would like to calculate cumsum of this serie but it should be reset (set to zero) at the location of the NaNs like below:</p>
  
  <pre><code>3382   0
  3381   0
  ...
  3369   0
  3368   0
  ...
  15     1
  10     0
  11     1
  12     2
  13     3
  9      0
  8      0
  7      0
  6      0
  3      0
  4      1
  5      2
  2      0
  1      0
  0      0
  </code></pre>
  
  <p>Ideally I would like to have a vectorized solution !</p>
  
  <p>I ever see a similar question with Matlab : 
  <a href="https://stackoverflow.com/questions/12995399/matlab-cumsum-reset-at-nan">Matlab cumsum reset at NaN?</a></p>
  
  <p>but I don't know how to translate this line <code>d = diff([0 c(n)]);</code> </p>