-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Implement __iter__ for Rolling and Expanding #34201
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 20 commits
7e461a1
1314059
8bcb313
24c3ede
dea38f2
cd9e7ac
e5e912b
045a76f
7e6779f
4d85ab9
fe74bc9
c0f4cf4
3bb2cf0
ac23518
7f74b79
5577efc
fd6e9a9
3cefb23
1623593
61af135
7e85f87
9b84e74
8379810
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 |
---|---|---|
|
@@ -648,6 +648,30 @@ from present information back to past information. This allows the rolling windo | |
Currently, this feature is only implemented for time-based windows. | ||
For fixed windows, the closed parameter cannot be set and the rolling window will always have both endpoints closed. | ||
|
||
.. _stats.rolling_window.iter: | ||
|
||
Iteration over window: | ||
~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
.. versionadded:: 1.1.0 | ||
|
||
It is allowed to iterate over the Series and DataFrame with the ``rolling`` and ``expanding`` window are | ||
support. | ||
|
||
Be noted that for ``rolling``, even if ``min_periods`` is greater than ``window`` size , we can still iterate | ||
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. I think this sentence can just note that 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. thanks, rephrased |
||
all the result out, although it will raise an error during aggregation. | ||
|
||
.. ipython:: python | ||
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. Think showing the dataframe case is enough. Also think we should 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. okay, removed series case, and also slightly change the ipython block to get web/doc check green. |
||
ser = pd.Series([1, 2, 3]).rolling(2) | ||
for i in ser: | ||
i | ||
|
||
.. ipython:: python | ||
df = pd.DataFrame({ "A": [1, 2, 3], "B": [4, 5, 6]}).rolling(2) | ||
for i in df: | ||
i | ||
|
||
|
||
.. _stats.moments.ts-versus-resampling: | ||
|
||
Time-aware rolling vs. resampling | ||
|
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.
Maybe just:
``Rolling`` and ``Expanding`` objects now support iteration.
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.
shortened