Examples
import numpy as np import pandas as pd
df = pd.DataFrame({'Q': [0, 3, 4, np.nan, 6]}) df
df.expanding(2).sum()