-
-
Notifications
You must be signed in to change notification settings - Fork 19k
DOC: Fix pandas.Series.resample docstring #23197
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 5 commits
2c23296
7940cbe
ff8009e
f71d48f
49fbd6b
b8f8b0e
ad1cada
ceff696
8cd9a89
ce7886a
abb2b58
bbddcd2
e0aef30
9b3c7d7
fab0ad0
7567e12
109e414
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 |
---|---|---|
|
@@ -7366,16 +7366,32 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None, | |
label=None, convention='start', kind=None, loffset=None, | ||
limit=None, base=0, on=None, level=None): | ||
""" | ||
Resample time-series data. | ||
|
||
Convenience method for frequency conversion and resampling of time | ||
series. Object must have a datetime-like index (DatetimeIndex, | ||
PeriodIndex, or TimedeltaIndex), or pass datetime-like values | ||
to the on or level keyword. | ||
series. Object must have a datetime-like index (``DatetimeIndex``, | ||
``PeriodIndex``, or ``TimedeltaIndex``), or pass datetime-like values | ||
to the ``on`` or ``level`` keyword. | ||
|
||
Parameters | ||
---------- | ||
rule : string | ||
|
||
the offset string or object representing target conversion | ||
The offset string or object representing target conversion. | ||
how : string | ||
Method for down-/re-sampling, default to ‘mean’ for downsampling. | ||
|
||
|
||
.. deprecated:: 0.18.0 | ||
The new syntax is ``.resample(...).mean()``, or | ||
``.resample(...).apply(<func>)`` | ||
axis : int, optional, default 0 | ||
|
||
Which index to use for up- or down-sampling. Must be | ||
``DatetimeIndex``, ``TimedeltaIndex`` or ``PeriodIndex``. | ||
|
||
fill_method : string, default None | ||
Filling method for upsampling. | ||
|
||
.. deprecated:: 0.18.0 | ||
The new syntax is ``.resample(...).<func>()``, | ||
e.g. ``.resample(...).pad()`` | ||
closed : {'right', 'left'} | ||
Which side of bin interval is closed. The default is 'left' | ||
for all frequency offsets except for 'M', 'A', 'Q', 'BM', | ||
|
@@ -7385,18 +7401,22 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None, | |
for all frequency offsets except for 'M', 'A', 'Q', 'BM', | ||
'BA', 'BQ', and 'W' which all have a default of 'right'. | ||
convention : {'start', 'end', 's', 'e'} | ||
|
||
For PeriodIndex only, controls whether to use the start or end of | ||
`rule` | ||
kind: {'timestamp', 'period'}, optional | ||
For ``PeriodIndex`` only, controls whether to use the start or | ||
end of ``rule``. | ||
|
||
kind : {'timestamp', 'period'} optional | ||
|
||
Pass 'timestamp' to convert the resulting index to a | ||
``DateTimeIndex`` or 'period' to convert it to a ``PeriodIndex``. | ||
By default the input representation is retained. | ||
loffset : timedelta | ||
Adjust the resampled time labels | ||
Adjust the resampled time labels. | ||
limit : int, default None | ||
Maximum size gap when reindexing with ``fill_method``. | ||
|
||
|
||
.. deprecated:: 0.18.0 | ||
base : int, default 0 | ||
For frequencies that evenly subdivide 1 day, the "origin" of the | ||
aggregated intervals. For example, for '5min' frequency, base could | ||
range from 0 through 4. Defaults to 0 | ||
range from 0 through 4. Defaults to 0. | ||
on : string, optional | ||
For a DataFrame, column to use instead of index for resampling. | ||
Column must be datetime-like. | ||
|
@@ -7405,7 +7425,7 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None, | |
|
||
level : string or int, optional | ||
For a MultiIndex, level (name or number) to use for | ||
resampling. Level must be datetime-like. | ||
resampling. ``level`` must be datetime-like. | ||
|
||
|
||
.. versionadded:: 0.19.0 | ||
|
||
|
@@ -7522,9 +7542,10 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None, | |
For a Series with a PeriodIndex, the keyword `convention` can be | ||
used to control whether to use the start or end of `rule`. | ||
|
||
>>> s = pd.Series([1, 2], index=pd.period_range('2012-01-01', | ||
freq='A', | ||
periods=2)) | ||
>>> s = pd.Series([1, 2], index=pd.period_range( | ||
... '2012-01-01', | ||
|
||
... freq='A', | ||
... periods=2)) | ||
>>> s | ||
2012 1 | ||
2013 2 | ||
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. In the following examples, when using resample, it once uses
Contributor
Author
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've created two examples, one sampling a year into quarters using |
||
|
@@ -7577,9 +7598,9 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None, | |
|
||
>>> time = pd.date_range('1/1/2000', periods=5, freq='T') | ||
>>> df2 = pd.DataFrame(data=10*[range(4)], | ||
|
||
columns=['a', 'b', 'c', 'd'], | ||
index=pd.MultiIndex.from_product([time, [1, 2]]) | ||
) | ||
... columns=['a', 'b', 'c', 'd'], | ||
... index=pd.MultiIndex.from_product([time, [1, 2]]) | ||
... ) | ||
>>> df2.resample('3T', level=0).sum() | ||
|
||
a b c d | ||
2000-01-01 00:00:00 0 6 12 18 | ||
jmrr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
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.
Single backticks.