@@ -4462,6 +4462,30 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None,
4462
4462
2000-01-01 00:06:00 26
4463
4463
Freq: 3T, dtype: int64
4464
4464
4465
+ For DataFrame objects, the keyword ``on`` can be used to specify the
4466
+ column instead of the index for resampling.
4467
+
4468
+ >>> df = pd.DataFrame(data=9*[range(4)], columns=['a', 'b', 'c', 'd'])
4469
+ >>> df['time'] = pd.date_range('1/1/2000', periods=9, freq='T')
4470
+ >>> df.resample('3T', on='time').sum()
4471
+ a b c d
4472
+ time
4473
+ 2000-01-01 00:00:00 0 3 6 9
4474
+ 2000-01-01 00:03:00 0 3 6 9
4475
+ 2000-01-01 00:06:00 0 3 6 9
4476
+
4477
+ For a DataFrame with MultiIndex, the keyword ``level`` can be used to
4478
+ specify on level the resampling needs to take place.
4479
+
4480
+ >>> time = pd.date_range('1/1/2000', periods=5, freq='T')
4481
+ >>> df2 = pd.DataFrame(data=10*[range(4)],
4482
+ columns=['a', 'b', 'c', 'd'],
4483
+ index=pd.MultiIndex.from_product([time, [1, 2]])
4484
+ )
4485
+ >>> df2.resample('3T', level=0).sum()
4486
+ a b c d
4487
+ 2000-01-01 00:00:00 0 6 12 18
4488
+ 2000-01-01 00:03:00 0 4 8 12
4465
4489
"""
4466
4490
from pandas .tseries .resample import (resample ,
4467
4491
_maybe_process_deprecations )
0 commit comments