Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
11 changes: 8 additions & 3 deletions pandas/tests/tseries/offsets/test_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from pandas._libs.tslibs import (
NaT,
Timedelta,
Timestamp,
conversion,
timezones,
Expand Down Expand Up @@ -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
Expand All @@ -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):
Expand Down