You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When doing a groupby on more than one column, the resulting MultiIndex does not seem to preserve the original column dtypes. I noticed it when working with Categorical columns, expecting CategoricalIndex when grouping on them, but this is only the case when grouping on just one column.
I did see that the behaviour was discussed in a PR, but it ultimately was not addressed.
I thought I'd quickly workaround it by converting the resulting MultiIndex to one with two CategoricalIndexs via reset_index() and set_index(), but it seems that set_index similarly forgets the column dtypes:
When doing a
groupby
on more than one column, the resultingMultiIndex
does not seem to preserve the original column dtypes. I noticed it when working withCategorical
columns, expectingCategoricalIndex
when grouping on them, but this is only the case when grouping on just one column.I did see that the behaviour was discussed in a PR, but it ultimately was not addressed.
Code Sample, a copy-pastable example if possible
Expected Output
output of
pd.show_versions()
The text was updated successfully, but these errors were encountered: