Skip to content

Commit 61b96f5

Browse files
committed
DOC: use substitution decorator for business month classes (pandas-dev#25828)
1 parent f2bcb9f commit 61b96f5

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

doc/example.feather

1.09 KB
Binary file not shown.

doc/source/whatsnew/v0.25.0.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Other Enhancements
3535
- :class:`RangeIndex` has gained :attr:`~RangeIndex.start`, :attr:`~RangeIndex.stop`, and :attr:`~RangeIndex.step` attributes (:issue:`25710`)
3636
- :class:`datetime.timezone` objects are now supported as arguments to timezone methods and constructors (:issue:`25065`)
3737
- :meth:`DataFrame.query` and :meth:`DataFrame.eval` now supports quoting column names with backticks to refer to names with spaces (:issue:`6508`)
38+
- :class:`CustomBusinessMonthBegin` and :class:`CustomBusinessMonthEnd` now use the substitution pattern for docstring sharing
3839

3940
.. _whatsnew_0250.api_breaking:
4041

pandas/tseries/offsets.py

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
# -*- coding: utf-8 -*-
2-
from datetime import date, datetime, timedelta
32
import functools
43
import operator
4+
from datetime import date, datetime, timedelta
55

6-
from dateutil.easter import easter
76
import numpy as np
7+
from dateutil.easter import easter
8+
from pandas._libs.tslibs.offsets import (
9+
ApplyTypeError, BaseOffset, _get_calendar, _is_normalized, _to_dt64,
10+
apply_index_wraps, as_datetime, roll_yearday, shift_month)
811

12+
import pandas.compat as compat
913
from pandas._libs.tslibs import (
1014
NaT, OutOfBoundsDatetime, Timedelta, Timestamp, ccalendar, conversion,
1115
delta_to_nanoseconds, frequencies as libfrequencies, normalize_date,
1216
offsets as liboffsets, timezones)
13-
from pandas._libs.tslibs.offsets import (
14-
ApplyTypeError, BaseOffset, _get_calendar, _is_normalized, _to_dt64,
15-
apply_index_wraps, as_datetime, roll_yearday, shift_month)
16-
import pandas.compat as compat
1717
from pandas.compat import range
18-
from pandas.errors import AbstractMethodError
19-
from pandas.util._decorators import cache_readonly
20-
2118
from pandas.core.dtypes.generic import ABCPeriod
22-
2319
from pandas.core.tools.datetimes import to_datetime
20+
from pandas.errors import AbstractMethodError
21+
from pandas.util._decorators import cache_readonly, Substitution, Appender
2422

2523
__all__ = ['Day', 'BusinessDay', 'BDay', 'CustomBusinessDay', 'CDay',
2624
'CBMonthEnd', 'CBMonthBegin',
@@ -973,7 +971,7 @@ class BusinessMonthBegin(MonthOffset):
973971
class _CustomBusinessMonth(_CustomMixin, BusinessMixin, MonthOffset):
974972
"""
975973
DateOffset subclass representing one custom business month, incrementing
976-
between [BEGIN/END] of month dates.
974+
between %(bound)s of month dates.
977975
978976
Parameters
979977
----------
@@ -1053,18 +1051,15 @@ def apply(self, other):
10531051
return result
10541052

10551053

1054+
@Substitution(bound="end")
1055+
@Appender(_CustomBusinessMonth.__doc__)
10561056
class CustomBusinessMonthEnd(_CustomBusinessMonth):
1057-
# TODO(py27): Replace condition with Subsitution after dropping Py27
1058-
if _CustomBusinessMonth.__doc__:
1059-
__doc__ = _CustomBusinessMonth.__doc__.replace('[BEGIN/END]', 'end')
10601057
_prefix = 'CBM'
10611058

10621059

1060+
@Substitution(bound="beginning")
1061+
@Appender(_CustomBusinessMonth.__doc__)
10631062
class CustomBusinessMonthBegin(_CustomBusinessMonth):
1064-
# TODO(py27): Replace condition with Subsitution after dropping Py27
1065-
if _CustomBusinessMonth.__doc__:
1066-
__doc__ = _CustomBusinessMonth.__doc__.replace('[BEGIN/END]',
1067-
'beginning')
10681063
_prefix = 'CBMS'
10691064

10701065

0 commit comments

Comments
 (0)