@@ -2737,14 +2737,31 @@ cdef class BYearBegin(YearOffset):
27372737 _prefix = " BYS"
27382738 _day_opt = " business_start"
27392739
2740+ # The pair of classes `_YearEnd` and `YearEnd` exist because of
2741+ # https://github.com/cython/cython/issues/3873
27402742
2741- cdef class YearEnd(YearOffset):
2743+ cdef class _YearEnd(YearOffset):
2744+ _default_month = 12
2745+ _prefix = " YE"
2746+ _day_opt = " end"
2747+
2748+ cdef readonly:
2749+ int _period_dtype_code
2750+
2751+ def __init__ (self , n = 1 , normalize = False , month = None ):
2752+ # Because YearEnd can be the freq for a Period, define its
2753+ # _period_dtype_code at construction for performance
2754+ YearOffset.__init__ (self , n, normalize, month)
2755+ self ._period_dtype_code = PeriodDtypeCode.A + self .month % 12
2756+
2757+
2758+ class YearEnd (_YearEnd ):
27422759 """
27432760 DateOffset increments between calendar year end dates.
27442761
27452762 YearEnd goes to the next date which is the end of the year.
27462763
2747- Attributes
2764+ Parameters
27482765 ----------
27492766 n : int, default 1
27502767 The number of years represented.
@@ -2778,18 +2795,8 @@ cdef class YearEnd(YearOffset):
27782795 Timestamp('2022-12-31 00:00:00')
27792796 """
27802797
2781- _default_month = 12
2782- _prefix = " YE"
2783- _day_opt = " end"
2784-
2785- cdef readonly:
2786- int _period_dtype_code
2787-
2788- def __init__ (self , n = 1 , normalize = False , month = None ):
2789- # Because YearEnd can be the freq for a Period, define its
2790- # _period_dtype_code at construction for performance
2791- YearOffset.__init__ (self , n, normalize, month)
2792- self ._period_dtype_code = PeriodDtypeCode.A + self .month % 12
2798+ def __new__ (cls , n = 1 , normalize = False , month = None ):
2799+ return _YearEnd.__new__ (cls , n, normalize, month)
27932800
27942801
27952802cdef class YearBegin(YearOffset):
@@ -5188,8 +5195,8 @@ def _warn_about_deprecated_aliases(name: str, is_period: bool) -> str:
51885195 warnings.warn(
51895196 f"\'{name}\' is deprecated and will be removed "
51905197 f"in a future version , please use "
5191- f"\'{c_PERIOD_AND_OFFSET_DEPR_FREQSTR.get(name )}\'"
5192- f" instead.",
5198+ f"\'{c_PERIOD_AND_OFFSET_DEPR_FREQSTR.get(name )}\' "
5199+ f"instead.",
51935200 FutureWarning ,
51945201 stacklevel = find_stack_level(),
51955202 )
@@ -5202,8 +5209,8 @@ def _warn_about_deprecated_aliases(name: str, is_period: bool) -> str:
52025209 warnings.warn(
52035210 f" \' {name}\' is deprecated and will be removed "
52045211 f" in a future version, please use "
5205- f" \' {_name}\' "
5206- f" instead." ,
5212+ f" \' {_name}\' "
5213+ f" instead." ,
52075214 FutureWarning ,
52085215 stacklevel = find_stack_level(),
52095216 )
0 commit comments