Skip to content
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 2 commits into from
Jul 16, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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],
Copy link
Contributor

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.

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
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Expand Down