Cumsum as a new column in an existing Pandas data

微笑、不失礼 提交于 2019-11-27 16:09:47
blacksite

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!