Reputation: 6305
exactly I mean :
suppose we have this pandas.DataFrame
:
and we want to expand summation on it! expected result:
Note that I want to know if there is a method in pandas
for this purpose or not? and I know that I can write code with for loops and etc. I'm looking for a method or module in pandas
package for this kind of calculations.
is there a pre-write method for this in pandas
?
Upvotes: 2
Views: 85
Reputation: 24049
You can use cumsum()
like below:
df = pd.DataFrame({
'col': [2,3,4,5]
})
df.cumsum()
Output:
col
0 2
1 5
2 9
3 14
Upvotes: 5