-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: Add example for pandas.DataFrame.rolling() with on
#50139
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 4 commits
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 |
---|---|---|
|
@@ -1110,6 +1110,35 @@ class Window(BaseWindow): | |
2 2.958621 | ||
3 NaN | ||
4 NaN | ||
|
||
**on** | ||
|
||
Rolling sum with a window length of 2 on specific columon. | ||
|
||
>>> df = pd.DataFrame({ | ||
... 'A': [pd.to_datetime('2020-01-01'), | ||
... pd.to_datetime('2020-01-01'), | ||
... pd.to_datetime('2020-01-02'),], | ||
... 'B': [1, 2, 3], }, | ||
... index=pd.date_range('2020', periods=3)) | ||
|
||
>>> df | ||
A B | ||
2020-01-01 2020-01-01 1 | ||
2020-01-02 2020-01-01 2 | ||
2020-01-03 2020-01-02 3 | ||
|
||
>>> df['B'].rolling('2D').sum() # to avoid warning when sum on 'A' | ||
2020-01-01 1.0 | ||
2020-01-02 3.0 | ||
2020-01-03 5.0 | ||
Freq: D, Name: B, dtype: float64 | ||
|
||
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. Seeing as you start with
we can probably exclude this example. If someone tries running it locally, then can remove |
||
>>> df.rolling('2D', on='A').sum() # value of 'B' differs from above | ||
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. let's remove the comment |
||
A B | ||
2020-01-01 2020-01-01 1.0 | ||
2020-01-02 2020-01-01 3.0 | ||
2020-01-03 2020-01-02 6.0 | ||
""" | ||
|
||
_attributes = [ | ||
|
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.
2 days?