Exception when grouping on a modified category · Issue #24740 · pandas-dev/pandas (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

@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!