@@ -7443,6 +7443,10 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None,
7443
7443
To learn more about the offset strings, please see `this link
7444
7444
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
7445
7445
7446
+ See Also
7447
+ --------
7448
+ groupby : Group by mapping, function, label, or list of labels.
7449
+
7446
7450
Examples
7447
7451
--------
7448
7452
@@ -7540,10 +7544,10 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None,
7540
7544
2000-01-01 00:06:00 26
7541
7545
Freq: 3T, dtype: int64
7542
7546
7543
- For a Series with a PeriodIndex, the keyword `convention` can be
7547
+ For a Series with a PeriodIndex, the keyword `` convention` ` can be
7544
7548
used to control whether to use the start or end of `rule`.
7545
7549
7546
- Resample a year by quarter using 'start' `convention`. Values are
7550
+ Resample a year by quarter using 'start' `` convention` `. Values are
7547
7551
assigned to the first quarter of the period.
7548
7552
7549
7553
>>> s = pd.Series([1, 2], index=pd.period_range('2012-01-01',
@@ -7564,12 +7568,12 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None,
7564
7568
2013Q4 NaN
7565
7569
Freq: Q-DEC, dtype: float64
7566
7570
7567
- Resample quarters by month using 'end' `convention`. Values are
7571
+ Resample quarters by month using 'end' `` convention` `. Values are
7568
7572
assigned to the last month of the period.
7569
7573
7570
7574
>>> q = pd.Series([1, 2, 3, 4], index=pd.period_range('2018-01-01',
7571
- ... freq='Q',
7572
- ... periods=4))
7575
+ ... freq='Q',
7576
+ ... periods=4))
7573
7577
>>> q
7574
7578
2018Q1 1
7575
7579
2018Q2 2
@@ -7589,7 +7593,7 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None,
7589
7593
2018-12 4.0
7590
7594
Freq: M, dtype: float64
7591
7595
7592
- For DataFrame objects, the keyword `on ` can be used to specify the
7596
+ For DataFrame objects, the keyword ``on` ` can be used to specify the
7593
7597
column instead of the index for resampling.
7594
7598
7595
7599
>>> d = dict({'price': [10, 11, 9, 13, 14, 18, 17, 19],
@@ -7615,21 +7619,33 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None,
7615
7619
2018-02-28 17.00 60.0
7616
7620
7617
7621
For a DataFrame with MultiIndex, the keyword ``level`` can be used to
7618
- specify on level the resampling needs to take place.
7619
-
7620
- >>> time = pd.date_range('1/1/2000', periods=5, freq='T')
7621
- >>> df2 = pd.DataFrame(data=10 * [range(4)],
7622
- ... columns=['a', 'b', 'c', 'd'],
7623
- ... index=pd.MultiIndex.from_product([time, [1, 2]])
7624
- ... )
7625
- >>> df2.resample('3T', level=0).sum()
7626
- a b c d
7627
- 2000-01-01 00:00:00 0 6 12 18
7628
- 2000-01-01 00:03:00 0 4 8 12
7622
+ specify on which level the resampling needs to take place.
7629
7623
7630
- See also
7631
- --------
7632
- groupby : Group by mapping, function, label, or list of labels.
7624
+ >>> days = pd.date_range('1/1/2000', periods=4, freq='D')
7625
+ >>> d2 = dict({'price': [10, 11, 9, 13, 14, 18, 17, 19],
7626
+ ... 'volume': [50, 60, 40, 100, 50, 100, 40, 50]})
7627
+ >>> df2 = pd.DataFrame(
7628
+ ... d2,
7629
+ ... index=pd.MultiIndex.from_product(
7630
+ ... [days, ['morning', 'afternoon']]
7631
+ ... )
7632
+ ... )
7633
+ >>> df2
7634
+ price volume
7635
+ 2000-01-01 morning 10 50
7636
+ afternoon 11 60
7637
+ 2000-01-02 morning 9 40
7638
+ afternoon 13 100
7639
+ 2000-01-03 morning 14 50
7640
+ afternoon 18 100
7641
+ 2000-01-04 morning 17 40
7642
+ afternoon 19 50
7643
+ >>> df2.resample('D', level=0).sum()
7644
+ price volume
7645
+ 2000-01-01 21 110
7646
+ 2000-01-02 22 140
7647
+ 2000-01-03 32 150
7648
+ 2000-01-04 36 90
7633
7649
"""
7634
7650
from pandas .core .resample import (resample ,
7635
7651
_maybe_process_deprecations )
0 commit comments