@@ -4826,6 +4826,8 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None,
4826
4826
label : {'right', 'left'}
4827
4827
Which bin edge label to label bucket with
4828
4828
convention : {'start', 'end', 's', 'e'}
4829
+ For PeriodIndex only, controls whether to use the start or end of
4830
+ `rule`
4829
4831
loffset : timedelta
4830
4832
Adjust the resampled time labels
4831
4833
base : int, default 0
@@ -4946,6 +4948,47 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None,
4946
4948
2000-01-01 00:06:00 26
4947
4949
Freq: 3T, dtype: int64
4948
4950
4951
+ For a Series with a PeriodIndex, the keyword `convention` can be
4952
+ used to control whether to use the start or end of `rule`.
4953
+
4954
+ >>> s = pd.Series([1, 2], index=pd.period_range('2012-01-01',
4955
+ freq='A',
4956
+ periods=2))
4957
+ >>> s
4958
+ 2012 1
4959
+ 2013 2
4960
+ Freq: A-DEC, dtype: int64
4961
+
4962
+ Resample by month using 'start' `convention`. Values are assigned to
4963
+ the first month of the period.
4964
+
4965
+ >>> s.resample('M', convention='start').asfreq().head()
4966
+ 2012-01 1.0
4967
+ 2012-02 NaN
4968
+ 2012-03 NaN
4969
+ 2012-04 NaN
4970
+ 2012-05 NaN
4971
+ Freq: M, dtype: float64
4972
+
4973
+ Resample by month using 'end' `convention`. Values are assigned to
4974
+ the last month of the period.
4975
+
4976
+ >>> s.resample('M', convention='end').asfreq()
4977
+ 2012-12 1.0
4978
+ 2013-01 NaN
4979
+ 2013-02 NaN
4980
+ 2013-03 NaN
4981
+ 2013-04 NaN
4982
+ 2013-05 NaN
4983
+ 2013-06 NaN
4984
+ 2013-07 NaN
4985
+ 2013-08 NaN
4986
+ 2013-09 NaN
4987
+ 2013-10 NaN
4988
+ 2013-11 NaN
4989
+ 2013-12 2.0
4990
+ Freq: M, dtype: float64
4991
+
4949
4992
For DataFrame objects, the keyword ``on`` can be used to specify the
4950
4993
column instead of the index for resampling.
4951
4994
0 commit comments