Skip to content

Commit 4314cbe

Browse files
committed
DOC: add example to Rolling docstring
1 parent 3fcd91b commit 4314cbe

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/core/window/rolling.py

+11
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,17 @@ class Window(_Window):
900900
3 2.0
901901
4 4.0
902902
903+
Same as above, but with forward-looking windows
904+
905+
>>> indexer = pd.api.indexers.FixedForwardWindowIndexer(window_size=2)
906+
>>> df.rolling(window=indexer, min_periods=1).sum()
907+
B
908+
0 1.0
909+
1 3.0
910+
2 2.0
911+
3 4.0
912+
4 4.0
913+
903914
A ragged (meaning not-a-regular frequency), time-indexed DataFrame
904915
905916
>>> df = pd.DataFrame({'B': [0, 1, 2, np.nan, 4]},

0 commit comments

Comments
 (0)