8000 DOC: update pandas.core.groupby.DataFrameGroupBy.resample docstring. by pandres · Pull Request #20374 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

DOC: update pandas.core.groupby.DataFrameGroupBy.resample docstring. #20374

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

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
Prev Previous commit
Next Next commit
Minor fixes
  • Loading branch information
datapythonista committed Nov 3, 2018
commit 4b55b5fd51447c43ab380cd7027860994c77bec9
27 changes: 12 additions & 15 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1294,13 +1294,11 @@ def describe(self, **kwargs):
return result.T
return result.unstack()

@Substitution(name='groupby')
@Appender(_doc_template)
def resample(self, rule, *args, **kwargs):
"""
Provide resampling when using a TimeGrouper.

Given a grouper the function resamples it according to a string
Given a grouper, the function resamples it according to a string
"string" -> "frequency".

See the :ref:`frequency aliases <timeseries.offset-aliases>`
Expand All @@ -1310,15 +1308,16 @@ def resample(self, rule, *args, **kwargs):
----------
rule : str or Offset
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offset --> DateOffset

The offset string or object representing target grouper conversion.
*args, **kwargs : [closed, label, loffset]
For compatibility with other groupby methods. See below for some
example parameters.
closed : {‘right’, ‘left’}
Which side of bin interval is closed.
label : {‘right’, ‘left’}
Which bin edge label to label bucket with.
loffset : timedelta
Adjust the resampled time labels.
*args, **kwargs
For compatibility with other groupby methods. Available keywor
arguments are:

* closed : {'right', 'left'}
Which side of bin interval is closed.
* label : {'right', 'left'}
Which bin edge label to label bucket with.
* loffset : timedelta
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is "loffset" right? I don't know this section of the code all that well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an expert myself, I guess the type should be DateOffset, tseries.offsets, timedelta, or str?

For what I can see, valid keywords should be how, fill_method, limit, kind and on (in get_resampler_for_grouping), closed, label, how, axis, fill_method, limit, loffset, kind, convention, base (in TimeGrouper), and key, level, freq, axis, sort (in Grouper).

What I'd do is to add the ones from get_resampler_for_grouping as explicit arguments, and then document that **kwargs will be passed to TimeGrouper.

@jreback is it ok to change the signature?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

level, axis, freq, key, sort are all part of the grouper and not args to .resample() or any aggregation function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pandres can you replace the description by something like:

Possible arguments are `how`, `fill_method`, `limit`, `kind` and `on`, and other arguments of `TimeGrouper`.

We can improve that later in a separate PR, but I think we can merge all the rest of the changes for now.

Thanks!

Adjust the resampled time labels.

Returns
-------
Expand All @@ -1327,15 +1326,13 @@ def resample(self, rule, *args, **kwargs):

See Also
--------
pandas.Grouper : specify a frequency to resample with when
pandas.Grouper : Specify a frequency to resample with when
grouping by a key.
DatetimeIndex.resample : Frequency conversion and resampling of
time series.

Examples
--------
Start by creating a length-4 DataFrame with minute frequency.

>>> idx = pd.date_range('1/1/2000', periods=4, freq='T')
>>> df = pd.DataFrame(data=4 * [range(2)],
... index=idx,
Expand Down
0