Skip to content

BUG: After reindex(), astype() raises exception for categorical series #17444

Closed
@junjiecai

Description

@junjiecai

Hi

I meet an unexpected behavior for categorical series

After reindex() a categorical series, astype() will raise Exception

For example, code below raise ValueError: Wrong number of dimensions

s = Series([1, 2, 3], index = [2, 0, 1])
(s.astype('category')
 .reindex([0, 1, 2])
 .astype(str))

However, if I reindex() first then set the series categorical, astype() works as expected.
Code below works fine

s = Series([1, 2, 3], index = [2, 0, 1])
(s.reindex([0, 1, 2])
 .astype('category')
 .astype(str))

I think both code should behave the same way

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions