Skip to content

Commit ac9f867

Browse files
committed
DOC: docstring for groupby.DataFrameGroupBy.resample.
1 parent d9331ff commit ac9f867

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

pandas/core/groupby.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,31 +1477,36 @@ def describe(self, **kwargs):
14771477
def resample(self, rule, *args, **kwargs):
14781478
"""Provide resampling when using a TimeGrouper.
14791479
1480-
Return a new grouper with our resampler appended
1480+
Given a grouper the function resamples it according to a string and an
1481+
optional list and dictionary of parameters. Returns a new grouper with
1482+
our resampler appended.
14811483
14821484
Parameters
14831485
----------
14841486
rule : str
1485-
The offset string or object representing target conversion.
1487+
The offset string or object representing target grouper conversion.
14861488
*args
14871489
These parameters will be passed to the get_resampler_for_grouping
1488-
function.
1490+
function which builds the approriate resampler and checks for
1491+
deprecated parameters.
14891492
**kwargs
14901493
These parameters will be passed to the get_resampler_for_grouping
1491-
function.
1494+
function which builds the approriate resampler and checks for
1495+
deprecated parameters.
14921496
14931497
Returns
14941498
-------
14951499
Grouper
1496-
Return a new grouper with our resampler appended
1500+
Return a new grouper with our resampler appended.
14971501
14981502
Examples
14991503
--------
15001504
15011505
Start by creating a DataFrame with 9 one minute timestamps.
1502-
>>> index = pd.date_range('1/1/2000', periods=9, freq='T')
1506+
1507+
>>> idx = pd.date_range('1/1/2000', periods=9, freq='T')
15031508
>>> df = pd.DataFrame(data=9*[range(4)],
1504-
... index=index,
1509+
... index=idx,
15051510
... columns=['a', 'b', 'c', 'd'])
15061511
>>> df.iloc[[6], [0]] = 5 # change a value for grouping
15071512
>>> df
@@ -1516,10 +1521,9 @@ def resample(self, rule, *args, **kwargs):
15161521
2000-01-01 00:07:00 0 1 2 3
15171522
2000-01-01 00:08:00 0 1 2 3
15181523
1519-
>>> series = pd.Series(range(9), index=index) # delete this
1520-
15211524
Downsample the DataFrame into 3 minute bins and sum the values of
15221525
the timestamps falling into a bin.
1526+
15231527
>>> df.groupby('a').resample('3T').sum()
15241528
a b c d
15251529
a
@@ -1529,6 +1533,7 @@ def resample(self, rule, *args, **kwargs):
15291533
5 2000-01-01 00:06:00 5 1 2 3
15301534
15311535
Upsample the series into 30 second bins.
1536+
15321537
>>> df.groupby('a').resample('30S').sum()
15331538
a b c d
15341539
a
@@ -1552,6 +1557,7 @@ def resample(self, rule, *args, **kwargs):
15521557
5 2000-01-01 00:06:00 5 1 2 3
15531558
15541559
Resample by month. Values are assigned to the month of the period.
1560+
15551561
>>> df.groupby('a').resample('M').sum()
15561562
a b c d
15571563
a

0 commit comments

Comments
 (0)