-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REF: No need to delegate to index check of whether an int is an int #21982
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
Codecov Report
@@ Coverage Diff @@
## master #21982 +/- ##
==========================================
- Coverage 91.96% 91.96% -0.01%
==========================================
Files 166 166
Lines 50334 50333 -1
==========================================
- Hits 46292 46291 -1
Misses 4042 4042
Continue to review full report at Codecov.
|
eec4dd5
to
06141c0
Compare
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.
Good change! (I have also always been annoyed if I saw that error :-))
@@ -2215,8 +2233,6 @@ def _getitem_axis(self, key, axis=None): | |||
|
|||
# a single integer | |||
else: | |||
key = self._convert_scalar_indexer(key, axis) |
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.
Can you check if there is any remaining occasion where _convert_scalar_indexer
is used for iloc
(in principle it shouldn't?). Because if not, _convert_scalar_indexer
has some redundant code
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, there is, and it was related to a commit I pushed but then removed, because unfortunately it broke some tests and I don't have time to check them in the next days. So I went for the obvious change only, will add the rest in some other PR (which I think will be quite large, as I will also touch code in indexes).
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.
OK. Can you point to where it is currently used? (to have this on record)
Is it worth to add a todo comment there?
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.
I'll rebase my other PR on this once merged, push it and open an issue referring to it
doc/source/whatsnew/v0.23.4.txt
Outdated
@@ -32,6 +32,7 @@ Bug Fixes | |||
|
|||
- Bug where calling :func:`DataFrameGroupBy.agg` with a list of functions including ``ohlc`` as the non-initial element would raise a ``ValueError`` (:issue:`21716`) | |||
- Bug in ``roll_quantile`` caused a memory leak when calling ``.rolling(...).quantile(q)`` with ``q`` in (0,1) (:issue:`21965`) | |||
- Passing a non-int scalar to ``.iloc`` now raises a more appropriate error message (:issue:`21982`) |
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 sure if it is worth to add a whatsnew for this.
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.
OK, removing
06141c0
to
3c07893
Compare
See #21989 for the more general issue. Ready to merge if there are no objections. |
@@ -50,7 +50,7 @@ def test_scalar_error(self): | |||
def f(): | |||
s.iloc[3.0] | |||
tm.assert_raises_regex(TypeError, | |||
'cannot do positional indexing', | |||
'Cannot index by location index', |
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.
side issue, we have 2 different versions of this error message (the original also happens), so these should be the same (future PR). I don't think we actually need to distinguish them.
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.
We already have both messages in the code (I did not write a new message).
The only difference is that now this case raises the correct one.
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.
can you add the test in top of the PR?
Hello @toobaz! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on July 20, 2018 at 13:23 Hours UTC |
86c2733
to
34cdc8e
Compare
lgtm. merge on green. |
git diff upstream/master -u -- "*.py" | flake8 --diff
Just fixing the following nonsensical error:
(you just cannot do positional indexing with a
str
, regardless of the index)... and adding a docstring while I was at it.