Skip to content

DOC: use substitution decorator for business month classes (#25828) #25868

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions pandas/tseries/offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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'])
Expand Down Expand Up @@ -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'


Expand Down