答案 0 :(得分:5)
您想要cumsum
:
df['Cumulative Frequency'] = df['Frequency'].cumsum()
示例:
In [23]:
df = pd.DataFrame({'Frequency':np.arange(10)})
df
Out[23]:
Frequency
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
In [24]:
df['Cumulative Frequency'] = df['Frequency'].cumsum()
df
Out[24]:
Frequency Cumulative Frequency
0 0 0
1 1 1
2 2 3
3 3 6
4 4 10
5 5 15
6 6 21
7 7 28
8 8 36
9 9 45