diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 7571202f02665..410995d8dec53 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1275,7 +1275,8 @@ def _add_timedeltalike_scalar(self, other): # PeriodArray overrides, so we only get here with DTA/TDA self = cast("DatetimeArray | TimedeltaArray", self) - other = Timedelta(other)._as_unit(self._unit) + other = Timedelta(other) + self, other = self._ensure_matching_resos(other) return self._add_timedeltalike(other) def _add_timedelta_arraylike(self, other: TimedeltaArray): diff --git a/pandas/tests/tseries/offsets/test_offsets.py b/pandas/tests/tseries/offsets/test_offsets.py index bca4ba98f37b7..95906224ee39b 100644 --- a/pandas/tests/tseries/offsets/test_offsets.py +++ b/pandas/tests/tseries/offsets/test_offsets.py @@ -19,6 +19,7 @@ from pandas._libs.tslibs import ( NaT, + Timedelta, Timestamp, conversion, timezones, @@ -566,6 +567,12 @@ def test_add_dt64_ndarray_non_nano(self, offset_types, unit, request): expected = dti._data + off result = dta + off + exp_unit = unit + if isinstance(off, Tick) and off._reso > dta._reso: + # cast to higher reso like we would with Timedelta scalar + exp_unit = Timedelta(off)._unit + expected = expected._as_unit(exp_unit) + if len(w): # PerformanceWarning was issued bc _apply_array raised, so we # fell back to object dtype, for which the code path does @@ -576,9 +583,7 @@ def test_add_dt64_ndarray_non_nano(self, offset_types, unit, request): ) request.node.add_marker(mark) - tm.assert_numpy_array_equal( - result._ndarray, expected._ndarray.astype(arr.dtype) - ) + tm.assert_numpy_array_equal(result._ndarray, expected._ndarray) class TestDateOffset(Base):