Skip to content

API: CategoricalDtype str, repr #17782

Closed
Closed
@TomAugspurger

Description

@TomAugspurger

I think that str(cat.dtype) should be changed back to always being 'category'. I've seen several places where people use str(thing.dtype) == 'category' as a way to check for Categoricals. Even subtle things like this arrow PR would break.

So instead of

In [6]: str(pd.Categorical([1, 2, 3]).dtype)
Out[6]: 'CategoricalDtype(categories=[1, 2, 3], ordered=False)'

it would be

Out[6]: 'category'

We can leave __repr__ to be unambiguous.

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