BUG: GroupBy.value_counts sorting order by rhshadrach · Pull Request #56016 · pandas-dev/pandas (original) (raw)
Thanks - good call. I added a test and found a bug calling .sortlevel()
in the categorical section. But the categorical behavior is still buggy here; namely
multi_index, _ = MultiIndex.from_product( |
---|
levels_list, names=[ping.name for ping in groupings] |
).sortlevel() |
is constructing the index by taking the cartesian product across all groupings; it should only be doing this for the categorical variables. That's not an easy fix, but will be handled in #55738 where we can just remove that whole block of code.