Skip to content

Commit ba029d1

Browse files
committed
BUG: Fix dt64[non_nano] + offset rounding
1 parent 4a4d976 commit ba029d1

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pandas/core/arrays/datetimes.py

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

7272
from pandas.tseries.frequencies import get_period_alias
7373
from pandas.tseries.offsets import (
74+
BusinessHour,
75+
CustomBusinessDay,
7476
Day,
7577
Tick,
7678
)
@@ -825,12 +827,13 @@ def _add_offset(self, offset: BaseOffset) -> Self:
825827
]
826828
res_unit = self.unit
827829
if hasattr(offset, "offset") and offset.offset is not None:
828-
offset_td = Timedelta(offset.offset)
829-
if offset_td.value != 0:
830-
offset_unit = offset_td.unit
831-
idx_self = units.index(self.unit)
832-
idx_offset = units.index(offset_unit)
833-
res_unit = units[min(idx_self, idx_offset)]
830+
if isinstance(offset, (CustomBusinessDay, BusinessHour)):
831+
offset_td = Timedelta(offset.offset)
832+
if offset_td.value != 0:
833+
offset_unit = offset_td.unit
834+
idx_self = units.index(self.unit)
835+
idx_offset = units.index(offset_unit)
836+
res_unit = units[min(idx_self, idx_offset)]
834837
result = type(self)._simple_new(res_values, dtype=res_values.dtype)
835838
result = result.as_unit(res_unit)
836839

0 commit comments

Comments
 (0)