1import pandas as pd
2from random import randint
3df = pd.DataFrame(data=[{'duration': randint(0,3)} for _ in range(5)])
4df.head()
5# duration
6# 0 0
7# 1 2
8# 2 1
9# 3 0
10# 4 3
11df['cum_dur'] = df.duration.cumsum()
12df.head()
13
14# duration cum_dur
15# 0 0 0
16# 1 2 2
17# 2 1 3
18# 3 0 3
19# 4 3 6