@@ -7589,18 +7589,30 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None,
7589
7589
2018-12 4.0
7590
7590
Freq: M, dtype: float64
7591
7591
7592
- For DataFrame objects, the keyword ``on` ` can be used to specify the
7592
+ For DataFrame objects, the keyword `on ` can be used to specify the
7593
7593
column instead of the index for resampling.
7594
7594
7595
- >>> df = pd.DataFrame(data=9 * [range(4)],
7596
- ... columns=['a', 'b', 'c', 'd'])
7597
- >>> df['time'] = pd.date_range('1/1/2000', periods=9, freq='T')
7598
- >>> df.resample('3T', on='time').sum()
7599
- a b c d
7600
- time
7601
- 2000-01-01 00:00:00 0 3 6 9
7602
- 2000-01-01 00:03:00 0 3 6 9
7603
- 2000-01-01 00:06:00 0 3 6 9
7595
+ >>> d = dict({'price': [10, 11, 9, 13, 14, 18, 17, 19],
7596
+ ... 'volume': [50, 60, 40, 100, 50, 100, 40, 50]})
7597
+ >>> df = pd.DataFrame(d)
7598
+ >>> df['week_starting'] = pd.date_range('01/01/2018',
7599
+ ... periods=8,
7600
+ ... freq='W')
7601
+ >>> df
7602
+ price volume week_starting
7603
+ 0 10 50 2018-01-07
7604
+ 1 11 60 2018-01-14
7605
+ 2 9 40 2018-01-21
7606
+ 3 13 100 2018-01-28
7607
+ 4 14 50 2018-02-04
7608
+ 5 18 100 2018-02-11
7609
+ 6 17 40 2018-02-18
7610
+ 7 19 50 2018-02-25
7611
+ >>> df.resample('M', on='week_starting').mean()
7612
+ price volume
7613
+ week_starting
7614
+ 2018-01-31 10.75 62.5
7615
+ 2018-02-28 17.00 60.0
7604
7616
7605
7617
For a DataFrame with MultiIndex, the keyword ``level`` can be used to
7606
7618
specify on level the resampling needs to take place.
0 commit comments