Skip to content

BUG: Break reference from grouping level to MI #31133

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 4 commits into from
Jan 20, 2020

Conversation

TomAugspurger
Copy link
Contributor

Closes #31068

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

is this just a regression in master? (so no note needed).

@@ -1235,6 +1235,9 @@ def _set_names(self, names, level=None, validate=True):
def _get_grouper_for_level(self, mapper, level):
indexer = self.codes[level]
level_index = self.levels[level]
# break references back to ourself so that setting the name
# on the output of a groupby doesn't reflect back here.
level_index = level_index.copy()
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need to do this here, rather do it as an else on line 1261 (add it); as take already copies, its just when that condition is not satisfied does it need a copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, I think. Added a case for Categorical grouper with unobserved categories, so I think all the cases are covered.

@TomAugspurger
Copy link
Contributor Author

is this just a regression in master? (so no note needed).

Yes, this is just a regression from 0.25.x

@jreback
Copy link
Contributor

jreback commented Jan 20, 2020

is this just a regression in master? (so no note needed).

Yes, this is just a regression from 0.25.x

your comments are conflicting, if this is from 0.25.x then we need a note

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

lgtm (ex whether we need a whatsnew or not).

@TomAugspurger
Copy link
Contributor Author

Sorry, I wasn't clear. by "from 0.25.x" I meant "after". This is fixing a regression that's only present on master, not 0.25.x.

@jreback jreback merged commit 29edd11 into pandas-dev:master Jan 20, 2020
@jreback
Copy link
Contributor

jreback commented Jan 20, 2020

thanks @TomAugspurger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

REGR: MultiIndex level names RuntimeError in groupby.apply
2 participants