Skip to content

Regression: Loc raising when indexing mi with one level #45785

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 2 commits into from
Feb 9, 2022

Conversation

phofl
Copy link
Member

@phofl phofl commented Feb 2, 2022

@jbrockmendel You moved the error catching logic out of maybe_mi_droplevels. Is this necessary for one of the other code paths?

@phofl phofl added Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex Regression Functionality that used to work in a prior pandas version labels Feb 2, 2022
@phofl phofl added this to the 1.4.1 milestone Feb 2, 2022
@@ -3128,7 +3128,12 @@ def maybe_mi_droplevels(indexer, levels):
# e.g. test_partial_string_timestamp_multiindex
return indexer, self[indexer]

return indexer, maybe_mi_droplevels(indexer, [level])
try:
result_index = maybe_mi_droplevels(indexer, [level])
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm can we handle this inside?

Copy link
Contributor

Choose a reason for hiding this comment

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

oh i c @jbrockmendel moved this. can you document this in the doc-string of maybe_mi_droplevels? (and prob should just move maybe_mi_droplevels) top a non-nested function (ok with these being a followup on main as well).

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a note. Would like to move in a separate pr to not backport this

Copy link
Contributor

Choose a reason for hiding this comment

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

great, yeah ideally clean in 1.5

@jreback jreback merged commit ff22bd6 into pandas-dev:main Feb 9, 2022
@jreback
Copy link
Contributor

jreback commented Feb 9, 2022

@meeseeksdev backport 1.4.x

@lumberbot-app

This comment was marked as resolved.

@lumberbot-app

This comment was marked as resolved.

@jreback
Copy link
Contributor

jreback commented Feb 9, 2022

@phofl if you wouldn't mind push a backport PR

@phofl
Copy link
Member Author

phofl commented Feb 14, 2022

Thx for the backport @simonjayhawkins

yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
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 MultiIndex Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Accessing a one-level MultiIndex with .loc raises with an unclear error (in 1.4)
3 participants