-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
PERF: do not check for label presence preventively #21594
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
doc/source/whatsnew/v0.24.0.txt
Outdated
@@ -198,6 +199,7 @@ Indexing | |||
^^^^^^^^ | |||
|
|||
- The traceback from a ``KeyError`` when asking ``.loc`` for a single missing label is now shorter and more clear (:issue:`21557`) | |||
- When ``.ix`` is asked for a missing integer label in a :class:`MultiIndex` with a first level of integer type, it now raises a ``KeyError``, consistently with the case of a flat :class:``Int64Index`` (:issue:`21593`) |
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.
Extra backticks in :class:``Int64Index``
Codecov Report
@@ Coverage Diff @@
## master #21594 +/- ##
==========================================
+ Coverage 91.9% 91.9% +<.01%
==========================================
Files 153 153
Lines 49547 49530 -17
==========================================
- Hits 45537 45523 -14
+ Misses 4010 4007 -3
Continue to review full report at Codecov.
|
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.
sufficient asv's here? small comments, otherwise lgtm.
doc/source/whatsnew/v0.24.0.txt
Outdated
@@ -130,6 +130,7 @@ Performance Improvements | |||
|
|||
- Improved performance of :func:`Series.describe` in case of numeric dtpyes (:issue:`21274`) | |||
- Improved performance of :func:`pandas.core.groupby.GroupBy.rank` when dealing with tied rankings (:issue:`21237`) | |||
- Improved performance of label indexing when key is a single label (:issue:`21594`) |
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.
mention / reference .loc/.at
here
@@ -230,7 +230,7 @@ def test_iloc_getitem_multiindex(self): | |||
# corner column | |||
rs = mi_int.iloc[2, 2] | |||
with catch_warnings(record=True): | |||
xp = mi_int.ix[:, 2].ix[2] |
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.
not that we care too much, but is this case looks slightly different from below (where testing for .ix
)?
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.
Yes, because as long as first level is non-int, .ix
is fine. Adding a comment.
doc/source/whatsnew/v0.24.0.txt
Outdated
@@ -198,6 +199,7 @@ Indexing | |||
^^^^^^^^ | |||
|
|||
- The traceback from a ``KeyError`` when asking ``.loc`` for a single missing label is now shorter and more clear (:issue:`21557`) | |||
- When ``.ix`` is asked for a missing integer label in a :class:`MultiIndex` with a first level of integer type, it now raises a ``KeyError``, consistently with the case of a flat :class:``Int64Index`` (:issue:`21593`) |
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.
what did this raise before? (or did it work?)
@jreback added a couple of comments, ready for me |
thanks @toobaz nice code removal! keep em coming! |
git diff upstream/master -u -- "*.py" | flake8 --diff
ASV run:
We don't check anymore if errors raised in indexing have to do with ordering different types (in Python 3)... but I can't think of any possible case (and none is present in the tests) in which looking for a single label could create a sorting problem.