Skip to content

ERR: Clarify exceptions for invalid datetimelike operations #17772

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 8 commits into from
Oct 8, 2017
Merged
Changes from 1 commit
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
19 changes: 17 additions & 2 deletions pandas/tests/indexes/datetimes/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,10 @@ def test_add_iadd(self):
Timestamp('2011-01-01') + idx

@pytest.mark.parametrize('addend', [
date_range('20130101', periods=3).tz_localize('US/Eastern'),
date_range('20110101', periods=3).tz_localize('US/Eastern'),
datetime(2011, 1, 1),
DatetimeIndex(['2011-01-01', '2011-01-02']),
np.datetime64('2005-02-25'),
np.datetime64('2011-01-01'),
Timestamp('2011-01-01'),
])
def test_add_datetimelike(self, addend):
Expand All @@ -458,6 +459,20 @@ def test_add_datetimelike(self, addend):
with tm.assert_raises_regex(TypeError, msg):
addend + dti

def test_add_dti_dti(self):
# previously performed setop (deprecated in 0.16.0)
# now raises TypeError (GH14164)

dti_tz = date_range('20110101', periods=3) \
.tz_localize('US/Eastern')
dti = date_range('20110101', periods=3)
combinations = product((dti_tz, dti), repeat=2)

msg = 'cannot add DatetimeIndex and DatetimeIndex'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can u parametrize this as well

for addend_1, addend_2 in combinations:
with tm.assert_raises_regex(TypeError, msg):
addend_1 + addend_2

def test_difference(self):
for tz in self.tz:
# diff
Expand Down