Skip to content

Instantly share code, notes, and snippets.

@yuyasugano
Created September 26, 2020 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuyasugano/3c27f7f14527c1b1cf71f1f003ceff16 to your computer and use it in GitHub Desktop.
Save yuyasugano/3c27f7f14527c1b1cf71f1f003ceff16 to your computer and use it in GitHub Desktop.
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