Repository: pandas-dev/pandas

Issue:
Use Substitution Decorator for CustomBusinessMonthEnd
This is a follow up to https://github.com/pandas-dev/pandas/pull/21093/files#r188805397 which wasn't working with Py27. Now that that is a thing of the past we should be able to use the more idiomatic Substitution approach to generating this docstring




Discussion:
Hi,
I would like to give it a try as a first contribution.
It does not seem to be very complex when looking at the contributing guide

Resolving patch:
diff --git a/pandas/tseries/offsets.py b/pandas/tseries/offsets.py
--- a/pandas/tseries/offsets.py
+++ b/pandas/tseries/offsets.py
@@ -15,7 +15,7 @@
     apply_index_wraps, as_datetime, roll_yearday, shift_month)
 import pandas.compat as compat
 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
 
@@ -971,21 +971,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
+        Calendar to integrate.
     offset : timedelta, default timedelta(0)
+        Time offset to apply.
     """
     _attributes = frozenset(['n', 'normalize',
                              'weekmask', 'holidays', 'calendar', 'offset'])
@@ -1052,18 +1056,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'
 
 


Test patch: