-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
ENH: sort=bool keyword argument for index.difference pandas-dev#17839
ENH: sort=bool keyword argument for index.difference pandas-dev#17839
@@ -2183,7 +2183,7 @@ def _get_consensus_name(self, other): | |||
return self._shallow_copy(name=name) | |||
return self | |||
|
|||
def union(self, other): | |||
def union(self, other, sort=True): |
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
.
[pandas] find ./pandas -type f | grep .py$ | xargs grep -n "def union" 17:41:36 ☁ fix-drop_duplicates-when-duplicate-column-names ☂ ✭
./pandas/core/common.py:353:def union(*seqs):
./pandas/core/dtypes/concat.py:214:def union_categoricals(to_union, sort_categories=False, ignore_order=False):
./pandas/core/indexes/base.py:2186: def union(self, other):
./pandas/core/indexes/datetimes.py:983: def union(self, other):
./pandas/core/indexes/datetimes.py:1036: def union_many(self, others):
./pandas/core/indexes/multi.py:2584: def union(self, other):
./pandas/core/indexes/range.py:416: def union(self, other):
./pandas/core/indexes/timedeltas.py:496: def union(self, other):
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 👍
Codecov Report
@@ Coverage Diff @@
## master #17878 +/- ##
==========================================
+ Coverage 91.23% 91.24% +<.01%
==========================================
Files 163 163
Lines 50102 50106 +4
==========================================
+ Hits 45712 45719 +7
+ Misses 4390 4387 -3
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #17878 +/- ##
==========================================
+ Coverage 91.23% 91.24% +0.01%
==========================================
Files 163 163
Lines 50102 50111 +9
==========================================
+ Hits 45712 45726 +14
+ Misses 4390 4385 -5
Continue to review full report at Codecov.
|
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
- Reference issue number
- Will need test cases that cause your code to issue the warnings you added
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.
@gfyoung any changes required?
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 Some cases will be unsorted even if sort=True
.
Like this.
https://github.com/pandas-dev/pandas/pull/17878/files#diff-248241e14f081931cc805f9d0e137a5fR2211
Hello @Giftlin! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on October 18, 2017 at 10:23 Hours UTC |
union = Index([]).union(first, sort=False) | ||
assert union is first | ||
|
||
# preserve names |
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.
pls dont' repeat code like this, use parametrize instead.
can you rebase and update according to comments |
@jreback Can I take over this issue? |
@Licht-T : Feel free to write your own patch and submit as a separate PR. |
git diff upstream/master -u -- "*.py" | flake8 --diff