-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Deprecated Index.get_duplicates() #20544
Conversation
Codecov Report
@@ Coverage Diff @@
## master #20544 +/- ##
==========================================
- Coverage 91.85% 91.84% -0.01%
==========================================
Files 153 153
Lines 49318 49311 -7
==========================================
- Hits 45299 45292 -7
Misses 4019 4019
Continue to review full report at Codecov.
|
@@ -2061,6 +2061,11 @@ def test_cached_properties_not_settable(self): | |||
with tm.assert_raises_regex(AttributeError, "Can't set attribute"): |
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.
need to remove the usage from all tests or catch the warnings
(pandas) bash-3.2$ grep -r get_duplicates pandas
pandas/core/reshape/concat.py: overlap = concat_index.get_duplicates()
Binary file pandas/core/reshape/__pycache__/concat.cpython-36.pyc matches
Binary file pandas/core/__pycache__/frame.cpython-36.pyc matches
pandas/core/frame.py: duplicates = index.get_duplicates()
Binary file pandas/core/indexes/__pycache__/datetimelike.cpython-36.pyc matches
Binary file pandas/core/indexes/__pycache__/base.cpython-36.pyc matches
pandas/core/indexes/datetimelike.py: def get_duplicates(self):
pandas/core/indexes/datetimelike.py: values = Index.get_duplicates(self)
pandas/core/indexes/base.py: def get_duplicates(self):
pandas/core/indexes/base.py: >>> pd.Index([1, 2, 2, 3, 3, 3, 4]).get_duplicates()
pandas/core/indexes/base.py: >>> pd.Index([1., 2., 2., 3., 3., 3., 4.]).get_duplicates()
pandas/core/indexes/base.py: >>> pd.Index(['a', 'b', 'b', 'c', 'c', 'c', 'd']).get_duplicates()
pandas/core/indexes/base.py: >>> pd.Index(dates).get_duplicates()
pandas/core/indexes/base.py: >>> pd.Index([1, 2, 3, 2, 3, 4, 3]).get_duplicates()
pandas/core/indexes/base.py: >>> pd.Index([1, 2, 3, 4]).get_duplicates()
pandas/core/indexes/base.py: >>> pd.Index(dates).get_duplicates()
pandas/core/indexes/base.py: _get_duplicates = get_duplicates
Binary file pandas/tests/indexes/__pycache__/test_multi.cpython-36-PYTEST.pyc matches
Binary file pandas/tests/indexes/datetimes/__pycache__/test_datetime.cpython-36-PYTEST.pyc matches
pandas/tests/indexes/datetimes/test_datetime.py: def test_get_duplicates(self):
pandas/tests/indexes/datetimes/test_datetime.py: result = idx.get_duplicates()
Binary file pandas/tests/indexes/timedeltas/__pycache__/test_timedelta.cpython-36-PYTEST.pyc matches
pandas/tests/indexes/timedeltas/test_timedelta.py: def test_get_duplicates(self):
pandas/tests/indexes/timedeltas/test_timedelta.py: result = idx.get_duplicates()
pandas/tests/indexes/test_multi.py: assert mi.get_duplicates() == []
pandas/tests/indexes/test_multi.py: assert mi.get_duplicates() == []
pandas/core/indexes/base.py
Outdated
|
||
return self._get_duplicates() | ||
|
||
def _get_duplicates(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.
would rather change the impl itself here as well to the suggested one
Hmm I made that change but it looks like this actually doesn't work for MultiIndexes mi = pd.MultiIndex.from_arrays([['a', 'b'], ['c', 'd']])
mi[mi.duplicated()].unique()
*** TypeError: Cannot infer number of levels from empty list Not being as familiar on the MI side of things, do you think it's worth creating that as a separate issue and merging before this (I think it's a problem with the |
this is a bug in
let's fix that one first, i'll create an issue. |
@WillAyd : fixed, can you rebase? |
|
||
with warnings.catch_warnings(record=True): | ||
# Deprecated - see GH20239 | ||
assert mi.get_duplicates().equals(MultiIndex.from_arrays( |
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.
Had to tweak the assertion here given the return value is no longer a list, though I assume you are aware of that from the original issue. With that said, this is a different behavior for non-datetimelikes (which were returning a like-Index object) - is it worth documenting that in the whatsnew or is this getting into too technical of a distinction?
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.
this is fine
can you rebase |
can you just check that we don't have any warnings showing from this |
Checked the output of |
thanks @WillAyd nice patch! |
git diff upstream/master -u -- "*.py" | flake8 --diff