Cumsum as a new column in an existing Pandas dataframe

Just apply cumsum on the pandas.Series df['SUM_C'] and assign it to a new column:

df['CUMSUM_C'] = df['SUM_C'].cumsum()

Result:

df
Out[34]: 
   A  B  SUM_C  CUMSUM_C
0  1  1     10       10
1  1  2     20       30

Leave a Comment