Skip to content

REGR: DataFrame.shift(axis=1) raises TypeError when columns is CategoricalIndex #38434

Closed
@topper-123

Description

@topper-123

A regression since 1.1:

>>> ci = pd.CategoricalIndex(["a", "b"])
>>> df = pd.DataFrame([[1, 2], [3, 4]], index=ci, columns=ci)
>>> df.shift(axis=0)  # ok
     a    b
a  NaN  NaN
b  1.0  2.0
>>> df.shift(axis=1)  # not ok, worked in v1.1
TypeError: 'fill_value=0' is not present in this Categorical's categories

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugCategoricalCategorical Data TypeRegressionFunctionality that used to work in a prior pandas version

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions