@@ -1477,31 +1477,36 @@ def describe(self, **kwargs):
1477
1477
def resample (self , rule , * args , ** kwargs ):
1478
1478
"""Provide resampling when using a TimeGrouper.
1479
1479
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.
1481
1483
1482
1484
Parameters
1483
1485
----------
1484
1486
rule : str
1485
- The offset string or object representing target conversion.
1487
+ The offset string or object representing target grouper conversion.
1486
1488
*args
1487
1489
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.
1489
1492
**kwargs
1490
1493
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.
1492
1496
1493
1497
Returns
1494
1498
-------
1495
1499
Grouper
1496
- Return a new grouper with our resampler appended
1500
+ Return a new grouper with our resampler appended.
1497
1501
1498
1502
Examples
1499
1503
--------
1500
1504
1501
1505
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')
1503
1508
>>> df = pd.DataFrame(data=9*[range(4)],
1504
- ... index=index ,
1509
+ ... index=idx ,
1505
1510
... columns=['a', 'b', 'c', 'd'])
1506
1511
>>> df.iloc[[6], [0]] = 5 # change a value for grouping
1507
1512
>>> df
@@ -1516,10 +1521,9 @@ def resample(self, rule, *args, **kwargs):
1516
1521
2000-01-01 00:07:00 0 1 2 3
1517
1522
2000-01-01 00:08:00 0 1 2 3
1518
1523
1519
- >>> series = pd.Series(range(9), index=index) # delete this
1520
-
1521
1524
Downsample the DataFrame into 3 minute bins and sum the values of
1522
1525
the timestamps falling into a bin.
1526
+
1523
1527
>>> df.groupby('a').resample('3T').sum()
1524
1528
a b c d
1525
1529
a
@@ -1529,6 +1533,7 @@ def resample(self, rule, *args, **kwargs):
1529
1533
5 2000-01-01 00:06:00 5 1 2 3
1530
1534
1531
1535
Upsample the series into 30 second bins.
1536
+
1532
1537
>>> df.groupby('a').resample('30S').sum()
1533
1538
a b c d
1534
1539
a
@@ -1552,6 +1557,7 @@ def resample(self, rule, *args, **kwargs):
1552
1557
5 2000-01-01 00:06:00 5 1 2 3
1553
1558
1554
1559
Resample by month. Values are assigned to the month of the period.
1560
+
1555
1561
>>> df.groupby('a').resample('M').sum()
1556
1562
a b c d
1557
1563
a
0 commit comments