-
-
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 3 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,29 @@ 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' : [1, 3, 5, np.nan, 7], | ||
... 'B' : [2, 4, np.nan, 6, 8]}) | ||
|
||
>>> df | ||
A B | ||
0 1.0 2.0 | ||
1 3.0 4.0 | ||
2 5.0 NaN | ||
3 NaN 6.0 | ||
4 7.0 8.0 | ||
|
||
>>> df.rolling(2, on='A').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. wouldn't this give the same result even without 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. Without
Do I need to add this result as comparison? 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 was thinking more something like In [62]: df = pd.DataFrame({
...: 'A': to_datetime(['2020-01-01', '2020-01-01', '2020-01-02']),
...: 'B': [1,2,3],
...: },
...: index=date_range('2020', periods=3)) in which if you do 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. Oh, I see what that means. How about the following:
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.
other than that, looks fine 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 for the correction, my English skills are a little rusty. |
||
A B | ||
0 1.0 NaN | ||
1 3.0 6.0 | ||
2 5.0 NaN | ||
3 NaN NaN | ||
4 7.0 14.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?