Skip to content

CLN: pandas/core/indexing.py #36713

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

Merged
merged 9 commits into from
Oct 7, 2020
Merged

Conversation

ivanovmg
Copy link
Member

@ivanovmg ivanovmg commented Sep 28, 2020

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

Slight clean-up of pandas/core/indexing.py.

  • Use suppress instead of try/except/pass (starting from Python 3.7)
  • Slight rearrangement of statements
  • Extract method _validate_key_length

@@ -834,11 +831,9 @@ def _getitem_nested_tuple(self, tup: Tuple):
if self.name != "loc":
# This should never be reached, but lets be explicit about it
raise ValueError("Too many indices")
try:
with suppress(IndexingError):
result = self._handle_lowerdim_multi_index_axis0(tup)
return result
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could avoid the declaration of result here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Changed.

@@ -782,14 +782,11 @@ def _getitem_lowerdim(self, tup: Tuple):
# ...but iloc should handle the tuple as simple integer-location
# instead of checking it as multiindex representation (GH 13797)
if isinstance(ax0, ABCMultiIndex) and self.name != "iloc":
try:
with suppress(IndexingError):
result = self._handle_lowerdim_multi_index_axis0(tup)
return result
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did that

@jbrockmendel
Copy link
Member

LGTM pending green.

If you're looking for high-value things to do in this file, narrowing what we're catching/suppressing is a never-ending battle.

@ivanovmg ivanovmg requested a review from phofl September 29, 2020 13:38
@phofl
Copy link
Member

phofl commented Sep 29, 2020

Lgtm

@ivanovmg
Copy link
Member Author

ivanovmg commented Oct 3, 2020

Can anyone re-start CI? Looks like there were internal CI engine failures.

@jreback jreback added Indexing Related to indexing on series/frames, not to indexes themselves Refactor Internal refactoring of code labels Oct 7, 2020
@jreback jreback added this to the 1.2 milestone Oct 7, 2020
@jreback jreback merged commit 09e7829 into pandas-dev:master Oct 7, 2020
@jreback
Copy link
Contributor

jreback commented Oct 7, 2020

thanks @ivanovmg nice cleanup

@ivanovmg ivanovmg deleted the refactor/indexing branch October 7, 2020 09:46
kesmit13 pushed a commit to kesmit13/pandas that referenced this pull request Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves Refactor Internal refactoring of code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants