Skip to content

Commit 8b70342

Browse files
committed
Addressed pandas-dev#46877 re-occurence
1 parent 78479a7 commit 8b70342

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pandas/_libs/tslibs/offsets.pyx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,12 +1221,12 @@ cdef class RelativeDeltaOffset(BaseOffset):
12211221
# perform calculation in UTC
12221222
other = other.replace(tzinfo=None)
12231223

1224-
if hasattr(self, "nanoseconds"):
1225-
td_nano = Timedelta(nanoseconds=self.nanoseconds)
1226-
else:
1227-
td_nano = Timedelta(other_nanos)
1224+
other = other + (self._offset * self.n)
12281225

1229-
other = other + ((self._offset + td_nano) * self.n)
1226+
if hasattr(self, "nanoseconds"):
1227+
other = self.n * Timedelta(nanoseconds=self.nanoseconds) + other
1228+
if other_nanos != 0:
1229+
other = Timedelta(nanoseconds=other_nanos) + other
12301230

12311231
if other_nanos != 0:
12321232
other = Timedelta(nanoseconds=other_nanos) + other

0 commit comments

Comments
 (0)