@@ -3712,7 +3712,7 @@ cdef shift_quarters(
3712
3712
const int64_t[:] dtindex ,
3713
3713
int quarters ,
3714
3714
int q1start_month ,
3715
- object day ,
3715
+ object day_opt ,
3716
3716
int modby = 3 ,
3717
3717
):
3718
3718
"""
@@ -3724,7 +3724,7 @@ cdef shift_quarters(
3724
3724
dtindex : int64_t[:] timestamps for input dates
3725
3725
quarters : int number of quarters to shift
3726
3726
q1start_month : int month in which Q1 begins by convention
3727
- day : {'start', 'end', 'business_start', 'business_end'}
3727
+ day_opt : {'start', 'end', 'business_start', 'business_end'}
3728
3728
modby : int (3 for quarters, 12 for years)
3729
3729
3730
3730
Returns
@@ -3737,9 +3737,9 @@ cdef shift_quarters(
3737
3737
int count = len (dtindex)
3738
3738
int months_to_roll, months_since, n, compare_day
3739
3739
bint roll_check
3740
- int64_t[:] out = np.empty(count, dtype = ' int64' )
3740
+ int64_t[:] out = np.empty(count, dtype = " int64" )
3741
3741
3742
- if day == ' start' :
3742
+ if day_opt == " start" :
3743
3743
with nogil:
3744
3744
for i in range (count):
3745
3745
if dtindex[i] == NPY_NAT:
@@ -3763,7 +3763,7 @@ cdef shift_quarters(
3763
3763
3764
3764
out[i] = dtstruct_to_dt64(& dts)
3765
3765
3766
- elif day == ' end' :
3766
+ elif day_opt == " end" :
3767
3767
with nogil:
3768
3768
for i in range (count):
3769
3769
if dtindex[i] == NPY_NAT:
@@ -3792,7 +3792,7 @@ cdef shift_quarters(
3792
3792
3793
3793
out[i] = dtstruct_to_dt64(& dts)
3794
3794
3795
- elif day == ' business_start' :
3795
+ elif day_opt == " business_start" :
3796
3796
with nogil:
3797
3797
for i in range (count):
3798
3798
if dtindex[i] == NPY_NAT:
@@ -3823,7 +3823,7 @@ cdef shift_quarters(
3823
3823
3824
3824
out[i] = dtstruct_to_dt64(& dts)
3825
3825
3826
- elif day == ' business_end' :
3826
+ elif day_opt == " business_end" :
3827
3827
with nogil:
3828
3828
for i in range (count):
3829
3829
if dtindex[i] == NPY_NAT:
@@ -3863,12 +3863,12 @@ cdef shift_quarters(
3863
3863
3864
3864
@ cython.wraparound (False )
3865
3865
@ cython.boundscheck (False )
3866
- def shift_months (const int64_t[:] dtindex , int months , object day = None ):
3866
+ def shift_months (const int64_t[:] dtindex , int months , object day_opt = None ):
3867
3867
"""
3868
3868
Given an int64-based datetime index, shift all elements
3869
3869
specified number of months using DateOffset semantics
3870
3870
3871
- day : {None, 'start', 'end'}
3871
+ day_opt : {None, 'start', 'end', 'business_start', 'business_end '}
3872
3872
* None: day of month
3873
3873
* 'start' 1st day of month
3874
3874
* 'end' last day of month
@@ -3879,9 +3879,9 @@ def shift_months(const int64_t[:] dtindex, int months, object day=None):
3879
3879
int count = len (dtindex)
3880
3880
int months_to_roll
3881
3881
bint roll_check
3882
- int64_t[:] out = np.empty(count, dtype = ' int64' )
3882
+ int64_t[:] out = np.empty(count, dtype = " int64" )
3883
3883
3884
- if day is None :
3884
+ if day_opt is None :
3885
3885
with nogil:
3886
3886
for i in range (count):
3887
3887
if dtindex[i] == NPY_NAT:
@@ -3894,7 +3894,7 @@ def shift_months(const int64_t[:] dtindex, int months, object day=None):
3894
3894
3895
3895
dts.day = min (dts.day, get_days_in_month(dts.year, dts.month))
3896
3896
out[i] = dtstruct_to_dt64(& dts)
3897
- elif day == ' start' :
3897
+ elif day_opt == " start" :
3898
3898
roll_check = False
3899
3899
if months <= 0 :
3900
3900
months += 1
@@ -3918,7 +3918,7 @@ def shift_months(const int64_t[:] dtindex, int months, object day=None):
3918
3918
dts.day = 1
3919
3919
3920
3920
out[i] = dtstruct_to_dt64(& dts)
3921
- elif day == ' end' :
3921
+ elif day_opt == " end" :
3922
3922
roll_check = False
3923
3923
if months > 0 :
3924
3924
months -= 1
@@ -3944,7 +3944,7 @@ def shift_months(const int64_t[:] dtindex, int months, object day=None):
3944
3944
dts.day = get_days_in_month(dts.year, dts.month)
3945
3945
out[i] = dtstruct_to_dt64(& dts)
3946
3946
3947
- elif day == ' business_start' :
3947
+ elif day_opt == " business_start" :
3948
3948
with nogil:
3949
3949
for i in range (count):
3950
3950
if dtindex[i] == NPY_NAT:
@@ -3964,7 +3964,7 @@ def shift_months(const int64_t[:] dtindex, int months, object day=None):
3964
3964
dts.day = get_firstbday(dts.year, dts.month)
3965
3965
out[i] = dtstruct_to_dt64(& dts)
3966
3966
3967
- elif day == ' business_end' :
3967
+ elif day_opt == " business_end" :
3968
3968
with nogil:
3969
3969
for i in range (count):
3970
3970
if dtindex[i] == NPY_NAT:
@@ -4060,13 +4060,11 @@ cdef int get_day_of_month(datetime other, day_opt) except? -1:
4060
4060
Parameters
4061
4061
----------
4062
4062
other : datetime or Timestamp
4063
- day_opt : 'start', 'end', 'business_start', 'business_end', or int
4063
+ day_opt : { 'start', 'end', 'business_start', 'business_end'}
4064
4064
'start': returns 1
4065
4065
'end': returns last day of the month
4066
4066
'business_start': returns the first business day of the month
4067
4067
'business_end': returns the last business day of the month
4068
- int: returns the day in the month indicated by `other`, or the last of
4069
- day the month if the value exceeds in that month's number of days.
4070
4068
4071
4069
Returns
4072
4070
-------
@@ -4095,9 +4093,6 @@ cdef int get_day_of_month(datetime other, day_opt) except? -1:
4095
4093
elif day_opt == ' business_end' :
4096
4094
# last business day of month
4097
4095
return get_lastbday(other.year, other.month)
4098
- elif is_integer_object(day_opt):
4099
- days_in_month = get_days_in_month(other.year, other.month)
4100
- return min (day_opt, days_in_month)
4101
4096
elif day_opt is None :
4102
4097
# Note: unlike `shift_month`, get_day_of_month does not
4103
4098
# allow day_opt = None
0 commit comments