-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN/API: clean-up of level argument of isin for indexes #26635
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
I think at least worth a whatsnew in case anyone out there was using this without worrying whether they are using an Index or MultiIndex in some ops |
Codecov Report
@@ Coverage Diff @@
## master #26635 +/- ##
==========================================
- Coverage 91.88% 91.86% -0.02%
==========================================
Files 174 174
Lines 50692 50687 -5
==========================================
- Hits 46576 46566 -10
- Misses 4116 4121 +5
Continue to review full report at Codecov.
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## master #26635 +/- ##
==========================================
- Coverage 91.88% 91.86% -0.02%
==========================================
Files 174 174
Lines 50692 50687 -5
==========================================
- Hits 46576 46566 -10
- Misses 4116 4121 +5
Continue to review full report at Codecov.
|
as a bug or an API change?
that's a possibility. do you think we need to deprecate first? |
API change. This does fall a little bit into a gray area though; deprecation would be safer but this is also clearly documented as only supported for MultiIndex, so maybe outright removal is OK. Let's see what others think |
@WillAyd : I could have this the wrong way round. it was added in and the api for levels defined in #7892. It looks like the documentation may be inconsistent. would need to add in the raises section and remove the level only being applicable to the MultiIndex We do have a variation though on the error raised, we are raising IndexError and KeyError for the level numbers and labels. If this is the defined api and as you said could be used in ops without needing to check the index type then all indexes must obey this interface and validate the input, i'll need to check the implementations of other index types to make sure. |
The docstring for Index.isin() states:
But the keyword is accepted by the other indexes, validated and raises if the level parameter does not match the only level in the index.
This PR removes the levels argument from the indexes (except MultiIndex)
Series.isin() and DataFrame.isin() do not have a level parameter, so isin for indexes will be consistent.
The implementation for MultiIndex.isin is independent from Index.isin, so i think that a separate docstring for MultiIndex would be much clearer. (but out of scope for this PR)
The docstring for datetimelike indexes does not include the level parameter but is not part of the published api, so has been removed to avoid confusion.
NOTE: This is not a change to the api, but a clean-up to match the api to the published api.