BUG: loc-indexing with a slice on a CategoricalIndex by topper-123 · Pull Request #30225 · pandas-dev/pandas (original) (raw)

#29922 didn't handle loc-indexing using a slice on non-string CategoricalIndexes. This fixes that. E.g. we had:

cat_idx = pd.CategoricalIndex([1,2,3], ordered=True) df = pd.DataFrame({"A": ["foo", "bar", "baz"]}, index=cat_idx) df.loc[1:2, "A"] TypeError: cannot do slice indexing on...

The above works now.