Skip to content

Revert "[BUG]: Fix regression when adding timeldeta_range to timestamp" #36616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 25, 2020
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
1 change: 0 additions & 1 deletion doc/source/whatsnew/v1.1.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Fixed regressions
- Fixed regression in :meth:`DataFrame.apply` with ``raw=True`` and user-function returning string (:issue:`35940`)
- Fixed regression when setting empty :class:`DataFrame` column to a :class:`Series` in preserving name of index in frame (:issue:`36527`)
- Fixed regression in :class:`Period` incorrect value for ordinal over the maximum timestamp (:issue:`36430`)
- Fixed regression when adding a :meth:`timedelta_range` to a :class:``Timestamp`` raised an ``ValueError`` (:issue:`35897`)

.. ---------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def _add_datetimelike_scalar(self, other):
result = checked_add_with_arr(i8, other.value, arr_mask=self._isnan)
result = self._maybe_mask_results(result)
dtype = DatetimeTZDtype(tz=other.tz) if other.tz else DT64NS_DTYPE
return DatetimeArray._simple_new(result, dtype=dtype, freq=self.freq)
return DatetimeArray(result, dtype=dtype, freq=self.freq)

def _addsub_object_array(self, other, op):
# Add or subtract Array-like of objects
Expand Down
17 changes: 0 additions & 17 deletions pandas/tests/arithmetic/test_timedelta64.py
Original file line number Diff line number Diff line change
Expand Up @@ -2136,20 +2136,3 @@ def test_td64arr_pow_invalid(self, scalar_td, box_with_array):

with pytest.raises(TypeError, match=pattern):
td1 ** scalar_td


def test_add_timestamp_to_timedelta():
# GH: 35897
timestamp = pd.Timestamp.now()
result = timestamp + pd.timedelta_range("0s", "1s", periods=31)
expected = pd.DatetimeIndex(
[
timestamp
+ (
pd.to_timedelta("0.033333333s") * i
+ pd.to_timedelta("0.000000001s") * divmod(i, 3)[0]
)
for i in range(31)
]
)
tm.assert_index_equal(result, expected)