Skip to content

Commit 87cbc42

Browse files
committed
BUG: Fix dt64[non_nano] + offset rounding
1 parent 00ad36c commit 87cbc42

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pandas/core/arrays/datetimes.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171

7272
from pandas.tseries.frequencies import get_period_alias
7373
from pandas.tseries.offsets import (
74-
DateOffset as TSeriesDateOffset,
74+
BusinessDay,
75+
DateOffset,
7576
Day,
7677
Tick,
7778
)
@@ -825,14 +826,18 @@ def _add_offset(self, offset: BaseOffset) -> Self:
825826
"s",
826827
]
827828
res_unit = self.unit
828-
if isinstance(offset, TSeriesDateOffset):
829+
if type(offset) is DateOffset:
830+
nano = offset.kwds.get("nanoseconds", 0)
829831
micro = offset.kwds.get("microseconds", 0)
830-
if micro and self.unit != "ns":
832+
if nano:
833+
res_unit = "ns"
834+
elif micro and self.unit != "ns":
831835
res_unit = "us"
832836
if (
833837
hasattr(offset, "offset")
834838
and offset.offset is not None
835839
and not isinstance(offset, Tick)
840+
and type(offset) is not BusinessDay
836841
):
837842
offset_td = Timedelta(offset.offset)
838843
if offset_td.value != 0:

0 commit comments

Comments
 (0)