-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: Added reverse rolling window examples #39091
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,6 +198,36 @@ from present information back to past information. This allows the rolling windo | |
|
||
df | ||
|
||
.. _window.reverse_rolling_window: | ||
|
||
Reverse rolling window | ||
~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
Get the window of a rolling function to look forward. | ||
|
||
Examples: | ||
|
||
.. ipython:: python | ||
|
||
# Using slicing | ||
# apply the rolling aggregation and then flip the result. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looking at other examples from this document, descriptions are typically outside the code blocks (rather than inside them as comments) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. Would be better if this description was a paragraph before the example. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done 👍 |
||
df = pd.DataFrame(data=[[pd.Timestamp('2018-01-01 00:00:00'), 100], | ||
[pd.Timestamp('2018-01-01 00:00:01'), 101], | ||
[pd.Timestamp('2018-01-01 00:00:03'), 103], | ||
[pd.Timestamp('2018-01-01 00:00:04'), 111]], | ||
columns=['time', 'value']).set_index('time') | ||
df | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you apply the |
||
|
||
df1 = df[::-1].rolling('2s').sum()[::-1] | ||
df1 | ||
|
||
# Using FixedForwardWindowIndexer | ||
# Creates window boundaries for fixed-length windows that include the current row. | ||
indexer = pd.api.indexers.FixedForwardWindowIndexer(window_size=2) | ||
|
||
df2 = df.rolling(window=indexer, min_periods=1).sum() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. name as above |
||
df2 | ||
|
||
|
||
.. _window.custom_rolling_window: | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you just add this as an example of using the
FixedForwardWindowIndexer
in theCustom window rolling
section below?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for late reply. Sure i will add it.