@@ -2737,14 +2737,31 @@ cdef class BYearBegin(YearOffset):
2737
2737
_prefix = " BYS"
2738
2738
_day_opt = " business_start"
2739
2739
2740
+ # The pair of classes `_YearEnd` and `YearEnd` exist because of
2741
+ # https://github.com/cython/cython/issues/3873
2740
2742
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 ):
2742
2759
"""
2743
2760
DateOffset increments between calendar year end dates.
2744
2761
2745
2762
YearEnd goes to the next date which is the end of the year.
2746
2763
2747
- Attributes
2764
+ Parameters
2748
2765
----------
2749
2766
n : int, default 1
2750
2767
The number of years represented.
@@ -2778,18 +2795,8 @@ cdef class YearEnd(YearOffset):
2778
2795
Timestamp('2022-12-31 00:00:00')
2779
2796
"""
2780
2797
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)
2793
2800
2794
2801
2795
2802
cdef class YearBegin(YearOffset):
@@ -5188,8 +5195,8 @@ def _warn_about_deprecated_aliases(name: str, is_period: bool) -> str:
5188
5195
warnings.warn(
5189
5196
f"\'{name}\' is deprecated and will be removed "
5190
5197
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.",
5193
5200
FutureWarning ,
5194
5201
stacklevel = find_stack_level(),
5195
5202
)
@@ -5202,8 +5209,8 @@ def _warn_about_deprecated_aliases(name: str, is_period: bool) -> str:
5202
5209
warnings.warn(
5203
5210
f" \' {name}\' is deprecated and will be removed "
5204
5211
f" in a future version, please use "
5205
- f" \' {_name}\' "
5206
- f" instead." ,
5212
+ f" \' {_name}\' "
5213
+ f" instead." ,
5207
5214
FutureWarning ,
5208
5215
stacklevel = find_stack_level(),
5209
5216
)
0 commit comments