If I have a dataframe with n rows, is there a way to set the ith row to be sum of row[i] and row[i-1] and do this so that the assignment to earlier rows is reflected in the latter rows? I would really like to avoid loops if possible.
Example DF:
SPY AAPL GOOG
2011-01-10 0.44 -0.81 1.80
2011-01-11 0.00 0.00 0.00
2011-01-12 -1.11 -2.77 -0.86
2011-01-13 -0.91 -4.02 -0.68
Sample pseudo code of summing two rows:
DF[2011-01-11] = DF[2011-01-10] + DF[2011-01-11]
DF[2011-01-12] = DF[2011-01-11] + DF[2011-01-12]
and so on.