I\'d like to build a running sum over a pandas dataframe. I have something like:
10/10/2012: 50, 0
10/11/2012: -10, 90
10/12/2012: 100, -5
<
As @JonClements mentions, you can do this using the cumsum DataFrame method:
from pandas import DataFrame
df = DataFrame({0: {'10/10/2012': 50, '10/11/2012': -10, '10/12/2012': 100}, 1: {'10/10/2012': 0, '10/11/2012': 90, '10/12/2012': -5}})
In [3]: df
Out[3]:
0 1
10/10/2012 50 0
10/11/2012 -10 90
10/12/2012 100 -5
In [4]: df.cumsum()
Out[4]:
0 1
10/10/2012 50 0
10/11/2012 40 90
10/12/2012 140 85