Skip to content

GroupBy Regression with Categorical On Master #29746

Closed
@WillAyd

Description

@WillAyd

Seems to be an issue on master as this works on 0.25.3:

>>> ser = pd.Series(pd.Categorical(["first", "second", "third", "fourth"], ordered=True))
>>> ser.groupby([1, 1, 1, 1]).first()
[first]
Categories (4, object): [first < fourth < second < third]

But fails on master:

>>> ser = pd.Series(pd.Categorical(["first", "second", "third", "fourth"], ordered=True))
>>> ser.groupby([1, 1, 1, 1]).first()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/williamayd/clones/pandas/pandas/core/groupby/groupby.py", line 1368, in f
    return self._cython_agg_general(alias, alt=npfunc, **kwargs)
  File "/Users/williamayd/clones/pandas/pandas/core/groupby/groupby.py", line 880, in _cython_agg_general
    obj._values, how, min_count=min_count
  File "/Users/williamayd/clones/pandas/pandas/core/groupby/ops.py", line 572, in aggregate
    "aggregate", values, how, axis, min_count=min_count
  File "/Users/williamayd/clones/pandas/pandas/core/groupby/ops.py", line 456, in _cython_operation
    "{dtype} dtype not supported".format(dtype=values.dtype)
NotImplementedError: category dtype not supported

@jbrockmendel for visibility. Looking at this on my end

Metadata

Metadata

Assignees

No one assigned

    Labels

    CategoricalCategorical Data TypeGroupbyRegressionFunctionality that used to work in a prior pandas version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions