diff --git a/doc/source/index.rst.template b/doc/source/index.rst.template index 8a72df0661fe4..40789d8def53d 100644 --- a/doc/source/index.rst.template +++ b/doc/source/index.rst.template @@ -113,7 +113,7 @@ programming language. :titlesonly: {{ single_doc[:-4] }} -{% elif single_doc and single_doc.count('.') <= 1 %} +{% elif single_doc and ((single_doc.count('.') <= 1) or ('tseries' in single_doc)) -%} .. autosummary:: :toctree: reference/api/ diff --git a/pandas/_libs/tslibs/offsets.pyi b/pandas/_libs/tslibs/offsets.pyi index a71aa42b4f671..94deadae256e6 100644 --- a/pandas/_libs/tslibs/offsets.pyi +++ b/pandas/_libs/tslibs/offsets.pyi @@ -156,7 +156,12 @@ class YearOffset(SingleConstructorOffset): class BYearEnd(YearOffset): ... class BYearBegin(YearOffset): ... -class YearEnd(YearOffset): ... + +class YearEnd(YearOffset): + def __new__( + cls, n: int = ..., normalize: bool = ..., month: int | None = ... + ) -> Self: ... + class YearBegin(YearOffset): ... class QuarterOffset(SingleConstructorOffset): diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 87214c3758d5c..9253adef369a5 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -2681,13 +2681,28 @@ cdef class BYearBegin(YearOffset): _day_opt = "business_start" -cdef class YearEnd(YearOffset): +cdef class _YearEnd(YearOffset): + _default_month = 12 + _prefix = "YE" + _day_opt = "end" + + cdef readonly: + int _period_dtype_code + + def __init__(self, n=1, normalize=False, month=None): + # Because YearEnd can be the freq for a Period, define its + # _period_dtype_code at construction for performance + YearOffset.__init__(self, n, normalize, month) + self._period_dtype_code = PeriodDtypeCode.A + self.month % 12 + + +class YearEnd(_YearEnd): """ DateOffset increments between calendar year end dates. YearEnd goes to the next date which is the end of the year. - Attributes + Parameters ---------- n : int, default 1 The number of years represented. @@ -2721,18 +2736,8 @@ cdef class YearEnd(YearOffset): Timestamp('2022-12-31 00:00:00') """ - _default_month = 12 - _prefix = "YE" - _day_opt = "end" - - cdef readonly: - int _period_dtype_code - - def __init__(self, n=1, normalize=False, month=None): - # Because YearEnd can be the freq for a Period, define its - # _period_dtype_code at construction for performance - YearOffset.__init__(self, n, normalize, month) - self._period_dtype_code = PeriodDtypeCode.A + self.month % 12 + def __new__(cls, n=1, normalize=False, month=None): + return _YearEnd.__new__(cls, n, normalize, month) cdef class YearBegin(YearOffset): @@ -5131,8 +5136,8 @@ def _warn_about_deprecated_aliases(name: str, is_period: bool) -> str: warnings.warn( f"\'{name}\' is deprecated and will be removed " f"in a future version, please use " - f"\'{c_PERIOD_AND_OFFSET_DEPR_FREQSTR.get(name)}\'" - f" instead.", + f"\'{c_PERIOD_AND_OFFSET_DEPR_FREQSTR.get(name)}\' " + f"instead.", FutureWarning, stacklevel=find_stack_level(), ) @@ -5145,8 +5150,8 @@ def _warn_about_deprecated_aliases(name: str, is_period: bool) -> str: warnings.warn( f"\'{name}\' is deprecated and will be removed " f"in a future version, please use " - f"\'{_name}\'" - f" instead.", + f"\'{_name}\' " + f"instead.", FutureWarning, stacklevel=find_stack_level(), )