Examples

In [4]:
import numpy as np
import pandas as pd
In [7]:
df = pd.DataFrame({'Q': [0, 3, 4, np.nan, 6]})
df
Out[7]:
Q
0 0.0
1 3.0
2 4.0
3 NaN
4 6.0
In [8]:
df.expanding(2).sum()
Out[8]:
Q
0 NaN
1 3.0
2 7.0
3 7.0
4 13.0