BUG: groupby with categorical drops empty groups when aggregating over a series #8870
Closed
2 tasks
Labels
Categorical
Categorical Data Type
good first issue
Groupby
Needs Tests
Unit test(s) needed to prevent regressions
Milestone
Hello,
When grouping a DataFrame over more than one column including a categorical, the empty groups are kept in the aggregation result. A test for this behaviour was introduced in #8138.
However, when performing aggregation on only one column of the DataFrame, the empty groups are dropped. This seems inconsistent to me and I guess that it's an edge case that wasn't thought of at the time.
fixed
inconsistent
expected
Note the strange ordering of the categorical index. I would expect
sorted = True
to sort by categorical level and not by lexical order?Also note that using
as_index=False
fails due to #8869The text was updated successfully, but these errors were encountered: