-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: Implement subtraction for object-dtype Index #21981
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -871,6 +871,18 @@ def test_sub(self): | |
pytest.raises(TypeError, lambda: index - index.tolist()) | ||
pytest.raises(TypeError, lambda: index.tolist() - index) | ||
|
||
def test_sub_object(self): | ||
# GH#19369 | ||
from decimal import Decimal | ||
index = pd.Index([Decimal(1), Decimal(2)]) | ||
expected = pd.Index([Decimal(0), Decimal(1)]) | ||
|
||
result = index - Decimal(1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you are exercising rsub? |
||
tm.assert_index_equal(result, expected) | ||
|
||
result = index - pd.Index([Decimal(1), Decimal(1)]) | ||
tm.assert_index_equal(result, expected) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we also add tests where element-wise subtraction should fail. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are already some in the test just above this, but more couldn’t hurt. Will do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, yes, thanks for pointing that out. Two things would be good there:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You got it. |
||
def test_map_identity_mapping(self): | ||
# GH 12766 | ||
# TODO: replace with fixture | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imports at the top