-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
BUG/PERF: MultiIndex.value_counts returning flat index #49558
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
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.
Two things:
Can we send this down a different path directly from MultiIndex.value_counts and what happens when bins is not None?
Edit: Missed the normalise part at the end, so forget my comment about sending it down a different path
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.
LGTM, pending green.
I also thought this path made sense since
|
|
Thx, could you open an issue about improving the error message? |
doc/source/whatsnew/v2.0.0.rst
Outdated
| - Bug in :meth:`MultiIndex.union` not sorting when sort=None and index contains missing values (:issue:`49010`) | ||
| - Bug in :meth:`MultiIndex.append` not checking names for equality (:issue:`48288`) | ||
| - Bug in :meth:`MultiIndex.symmetric_difference` losing extension array (:issue:`48607`) | ||
| - Bug in :meth:`MultiIndex.value_counts` returning a :class:`Series` indexed by flat index of tuples (:issue:`49558`) |
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.
| - Bug in :meth:`MultiIndex.value_counts` returning a :class:`Series` indexed by flat index of tuples (:issue:`49558`) | |
| - Bug in :meth:`MultiIndex.value_counts` returning a :class:`Series` indexed by flat index of tuples instead of a :class:`MultiIndex` (:issue:`49558`) |
Nit
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.
updated, thanks
will do |
mroeschke
left a comment
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.
LGTM merge when ready @phofl
|
thx @lukemanley |
doc/source/whatsnew/v2.0.0.rstfile if fixing a bug or adding a new feature.I believe it is a bug that
MultiIndex.value_countsreturns aSeriesindexed by a flat index of tuples rather than aMultiIndex. By returning a flat index, we lose nullable dtypes, index names, etc.This PR changes
MultiIndex.value_countsto return aSeriesindexed by aMultiIndex.This also has some perf improvements: