I looked a bit into this and have a question about the preferred solution: Is it ok to replace the nan with a unique string/integer before calling values = Categorical(self.grouper) and changing it back afterwards? Only in case of ``dropna=False```of course.
I think a better solution would just be to refactor the code path to use the logic used for multi group keys since I don't think it's planned to support Categorical(..., dropna=False)
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample, a copy-pastable example
Problem description
The grouping codes + indices are determined for a single group by key here
pandas/pandas/core/groupby/grouper.py
Line 559 in aefae55
And
Categorical
does not supportnan
as a label (only a missing -1 code)This works correctly if multiple group keys are passed
Once this issue is addressed, #35542 will be fixed
Expected Output
The text was updated successfully, but these errors were encountered: