From f6959d3d3f219f4810720170df281759d6dbb835 Mon Sep 17 00:00:00 2001 From: Alexandre Batisse Date: Mon, 25 Mar 2019 14:15:04 +0100 Subject: [PATCH 1/2] DOC: use substitution decorator for business month classes (#25828) --- pandas/tseries/offsets.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/pandas/tseries/offsets.py b/pandas/tseries/offsets.py index f208ce37a3b14..076e8d26994eb 100644 --- a/pandas/tseries/offsets.py +++ b/pandas/tseries/offsets.py @@ -16,7 +16,7 @@ import pandas.compat as compat from pandas.compat import range from pandas.errors import AbstractMethodError -from pandas.util._decorators import cache_readonly +from pandas.util._decorators import Appender, Substitution, cache_readonly from pandas.core.dtypes.generic import ABCPeriod @@ -972,21 +972,25 @@ class BusinessMonthBegin(MonthOffset): class _CustomBusinessMonth(_CustomMixin, BusinessMixin, MonthOffset): """ - DateOffset subclass representing one custom business month, incrementing - between [BEGIN/END] of month dates. + DateOffset subclass representing custom business month(s). + + Increments between %(bound)s of month dates. Parameters ---------- n : int, default 1 + The number of months represented. normalize : bool, default False - Normalize start/end dates to midnight before generating date range + Normalize start/end dates to midnight before generating date range. weekmask : str, Default 'Mon Tue Wed Thu Fri' - weekmask of valid business days, passed to ``numpy.busdaycalendar`` + Weekmask of valid business days, passed to ``numpy.busdaycalendar``. holidays : list - list/array of dates to exclude from the set of valid business days, - passed to ``numpy.busdaycalendar`` + List/array of dates to exclude from the set of valid business days, + passed to ``numpy.busdaycalendar``. calendar : pd.HolidayCalendar or np.busdaycalendar + A business day calendar. offset : timedelta, default timedelta(0) + Applies a time offset (from ms to years). """ _attributes = frozenset(['n', 'normalize', 'weekmask', 'holidays', 'calendar', 'offset']) @@ -1053,18 +1057,15 @@ def apply(self, other): return result +@Substitution(bound="end") +@Appender(_CustomBusinessMonth.__doc__) class CustomBusinessMonthEnd(_CustomBusinessMonth): - # TODO(py27): Replace condition with Subsitution after dropping Py27 - if _CustomBusinessMonth.__doc__: - __doc__ = _CustomBusinessMonth.__doc__.replace('[BEGIN/END]', 'end') _prefix = 'CBM' +@Substitution(bound="beginning") +@Appender(_CustomBusinessMonth.__doc__) class CustomBusinessMonthBegin(_CustomBusinessMonth): - # TODO(py27): Replace condition with Subsitution after dropping Py27 - if _CustomBusinessMonth.__doc__: - __doc__ = _CustomBusinessMonth.__doc__.replace('[BEGIN/END]', - 'beginning') _prefix = 'CBMS' From 540e18e59f6ff8cbe519549322c3168962999220 Mon Sep 17 00:00:00 2001 From: Alexandre Batisse Date: Tue, 26 Mar 2019 16:55:58 +0100 Subject: [PATCH 2/2] DOC: reword custom business month offset args descriptions --- pandas/tseries/offsets.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tseries/offsets.py b/pandas/tseries/offsets.py index 7786b4b43507b..bda0c4ec1237a 100644 --- a/pandas/tseries/offsets.py +++ b/pandas/tseries/offsets.py @@ -987,9 +987,9 @@ class _CustomBusinessMonth(_CustomMixin, BusinessMixin, MonthOffset): List/array of dates to exclude from the set of valid business days, passed to ``numpy.busdaycalendar``. calendar : pd.HolidayCalendar or np.busdaycalendar - A business day calendar. + Calendar to integrate. offset : timedelta, default timedelta(0) - Applies a time offset (from ms to years). + Time offset to apply. """ _attributes = frozenset(['n', 'normalize', 'weekmask', 'holidays', 'calendar', 'offset'])