-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: sort=bool keyword argument for index.difference #17878
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 7 commits
b8fe2e8
5e1ee8b
36c85ab
f831506
8145a28
f11a40e
a8d6259
d749e8d
193b7dd
17767bf
5039133
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 |
---|---|---|
|
@@ -896,6 +896,33 @@ def test_difference(self): | |
assert len(result) == 0 | ||
assert result.name == first.name | ||
|
||
def test_difference_sorting_false(self): | ||
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 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. @gfyoung any changes required? 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. @Giftlin Some cases will be unsorted even if |
||
|
||
first = pd.Index([2, 0, 4, 3]) | ||
second = pd.Index([2, 1]) | ||
answer = pd.Index([0, 4, 3]) | ||
first.name = 'name' | ||
# different names | ||
result = first.difference(second, sort=False) | ||
|
||
assert tm.equalContents(result, answer) | ||
assert result.name is None | ||
|
||
# same names | ||
second.name = 'name' | ||
result = first.difference(second, sort=False) | ||
assert result.name == 'name' | ||
|
||
# with empty | ||
result = first.difference([], sort=False) | ||
assert tm.equalContents(result, first) | ||
assert result.name == first.name | ||
|
||
# with everything | ||
result = first.difference(first, sort=False) | ||
assert len(result) == 0 | ||
assert result.name == first.name | ||
|
||
def test_symmetric_difference(self): | ||
# smoke | ||
idx1 = Index([1, 2, 3, 4], name='idx1') | ||
|
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.
You need to implement this in subclasses of
Index
, eg.DatetimeIndex
.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.
@Giftlin : I don't think you have addressed this comment yet.
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.
Oh yeah.. will do it 👍