Skip to content

Exception when grouping on a modified category #24740

Closed
@phil65

Description

@phil65

Code Sample, a copy-pastable example if possible

import pandas as pd

ds = pd.DataFrame({"a": [1, 2, 3], "b": ["a", "b", "c"]}) 
ds["b"] = ds["b"].astype("category")
ds['b'].cat.remove_categories(['a'], inplace=True)

# works
ds.groupby("b").groups

# gives ValueError: Categorial categories cannot be null 
ds.groupby("b", observed=True).groups

Problem description

I wonder if that exception should be raised there?
Using 0.24 RC1

Thanks to all working on pandas!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions