Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pandas DataFrame tips
print(df.rolling(3, min_periods=2).sum())
num
0 NaN
1 1.0
2 3.0
3 6.0
4 9.0
5 12.0
6 15.0
7 18.0
8 21.0
9 24.0
print(df.rolling(3, min_periods=1).sum())
num
0 0.0
1 1.0
2 3.0
3 6.0
4 9.0
5 12.0
6 15.0
7 18.0
8 21.0
9 24.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment