-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
DOC: document convention argument for resample() #16965
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4826,6 +4826,8 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None, | |
label : {'right', 'left'} | ||
Which bin edge label to label bucket with | ||
convention : {'start', 'end', 's', 'e'} | ||
For PeriodIndex only, controls whether to use the start or end of | ||
`rule` | ||
loffset : timedelta | ||
Adjust the resampled time labels | ||
base : int, default 0 | ||
|
@@ -4946,6 +4948,50 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None, | |
2000-01-01 00:06:00 26 | ||
Freq: 3T, dtype: int64 | ||
|
||
For a Series with a PeriodIndex, the keyword ``convention`` can be | ||
used to control whether to use the start or end of ``rule``. | ||
|
||
>>> series_p = pd.Series([1, 2], | ||
index=pd.period_range('2012-01-01', | ||
freq='A', | ||
periods=2 | ||
) | ||
) | ||
>>> series_p | ||
2012 1 | ||
2013 2 | ||
Freq: A-DEC, dtype: int64 | ||
|
||
Resample by month using 'start' ``convention``. Values are assigned to | ||
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. you don't need convertion to be in double-backticks here |
||
the first month of the period. | ||
|
||
>>> series_p.resample('M', convention='start').asfreq().head() | ||
2012-01 1.0 | ||
2012-02 NaN | ||
2012-03 NaN | ||
2012-04 NaN | ||
2012-05 NaN | ||
Freq: M, dtype: float64 | ||
|
||
Resample by month using 'end' ``convention``. Values are assigned to | ||
the last month of the period. | ||
|
||
>>> series_p.resample('M', convention='end').asfreq() | ||
2012-12 1.0 | ||
2013-01 NaN | ||
2013-02 NaN | ||
2013-03 NaN | ||
2013-04 NaN | ||
2013-05 NaN | ||
2013-06 NaN | ||
2013-07 NaN | ||
2013-08 NaN | ||
2013-09 NaN | ||
2013-10 NaN | ||
2013-11 NaN | ||
2013-12 2.0 | ||
Freq: M, dtype: float64 | ||
|
||
For DataFrame objects, the keyword ``on`` can be used to specify the | ||
column instead of the index for resampling. | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
just call this s, your lines are too long I think as well.