Skip to content
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

BUG/ENH: groupby quantile arraylike fails with integer columns #30462

Conversation

fujiaxiang
Copy link
Member

@fujiaxiang fujiaxiang commented Dec 25, 2019

When columns are integers, df.groupby(label).quantile(<arraylike>) fails.
This PR fixes this issue by telling MultiIndex to only look for positional levels during an reordering operation.
Two new internal methods in MultiIndex class, and one new parameter for DataFrame.reorder_levels and MultiIndex.reorder_levels are added during the debugging process.

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.

this is not the right solution as we are not adding a confusing at best parameter to a public function

this entire routine needs to be refactored to avoid the current method which is highly suspect now

@fujiaxiang
Copy link
Member Author

fujiaxiang commented Dec 25, 2019

this is not the right solution as we are not adding a confusing at best parameter to a public function

this entire routine needs to be refactored to avoid the current method which is highly suspect now

hi Jeff, thanks for review.
Now that I think about it, I agree with you this solution is too rough.
The idea of positional parameter came from the discussions in the issue (#30289).
By "this entire routine needs to be refactored" I assume you mean GroupBy.quantile should not rely on DataFrame.reorder_levels at all? Could you let me know a bit more details about the design you are thinking of?
Anyway, should I close this PR and start another one when ready? Or do you think maybe some of it is useful and I should keep this?

@jreback
Copy link
Contributor

jreback commented Dec 25, 2019

group by quantile needs the refactor to avoid the need to reindex the multiindex which is causing the issue now)

you can close or push to this PR up to u

@fujiaxiang
Copy link
Member Author

Sorry I messed up the different commits and reverts in this branch. Will close this PR and open a new one.

@fujiaxiang fujiaxiang closed this Dec 26, 2019
@fujiaxiang fujiaxiang deleted the bug_groupby_quantile_arraylike_fails branch January 3, 2020 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

groupby.quantile(<arraylike>) fails with AssertionError
2 participants