@@ -557,7 +557,7 @@ cdef class BaseOffset:
557
557
# ------------------------------------------------------------------
558
558
559
559
@apply_index_wraps
560
- def apply_index(self , index ):
560
+ def apply_index(self , dtindex ):
561
561
"""
562
562
Vectorized apply of DateOffset to DatetimeIndex,
563
563
raises NotImplementedError for offsets without a
@@ -1029,7 +1029,7 @@ cdef class RelativeDeltaOffset(BaseOffset):
1029
1029
return other + timedelta(self .n)
1030
1030
1031
1031
@apply_index_wraps
1032
- def apply_index (self , index ):
1032
+ def apply_index (self , dtindex ):
1033
1033
"""
1034
1034
Vectorized apply of DateOffset to DatetimeIndex,
1035
1035
raises NotImplementedError for offsets without a
@@ -1041,8 +1041,9 @@ cdef class RelativeDeltaOffset(BaseOffset):
1041
1041
1042
1042
Returns
1043
1043
-------
1044
- DatetimeIndex
1044
+ ndarray[datetime64[ns]]
1045
1045
"""
1046
+ dt64other = np.asarray(dtindex)
1046
1047
kwds = self .kwds
1047
1048
relativedelta_fast = {
1048
1049
" years" ,
@@ -1059,12 +1060,12 @@ cdef class RelativeDeltaOffset(BaseOffset):
1059
1060
1060
1061
months = (kwds.get(" years" , 0 ) * 12 + kwds.get(" months" , 0 )) * self .n
1061
1062
if months:
1062
- shifted = shift_months(index.asi8 , months)
1063
- index = type (index)( shifted, dtype = index.dtype )
1063
+ shifted = shift_months(dt64other.view( " i8 " ) , months)
1064
+ dt64other = shifted.view( " datetime64[ns] " )
1064
1065
1065
1066
weeks = kwds.get(" weeks" , 0 ) * self .n
1066
1067
if weeks:
1067
- index = index + timedelta (days = 7 * weeks)
1068
+ dt64other = dt64other + Timedelta (days = 7 * weeks)
1068
1069
1069
1070
timedelta_kwds = {
1070
1071
k: v
@@ -1073,11 +1074,11 @@ cdef class RelativeDeltaOffset(BaseOffset):
1073
1074
}
1074
1075
if timedelta_kwds:
1075
1076
delta = Timedelta(** timedelta_kwds)
1076
- index = index + (self .n * delta)
1077
- return index
1077
+ dt64other = dt64other + (self .n * delta)
1078
+ return dt64other
1078
1079
elif not self ._use_relativedelta and hasattr (self , " _offset" ):
1079
1080
# timedelta
1080
- return index + (self ._offset * self .n)
1081
+ return dt64other + Timedelta (self ._offset * self .n)
1081
1082
else :
1082
1083
# relativedelta with other keywords
1083
1084
kwd = set (kwds) - relativedelta_fast
0 commit comments