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 a15376db8f8c2..461f5180e4ed9 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 aa95143c6ae62..f07efa91cda0e 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -2737,14 +2737,31 @@ cdef class BYearBegin(YearOffset): _prefix = "BYS" _day_opt = "business_start" +# The pair of classes `_YearEnd` and `YearEnd` exist because of +# https://github.com/cython/cython/issues/3873 -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. @@ -2778,18 +2795,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): @@ -5188,8 +5195,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(), ) @@ -5202,8 +5209,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(), )