Skip to content

str.cat inconsistent for CategoricalIndex #20842

Closed
@h-vetinari

Description

@h-vetinari

The str.cat-accessor works for CategoricalIndex as target, but not as caller. This is inconsistent.

a = pd.Index(['a', 'b', 'a'])
b = pd.Index(['a', 'b', 'a'], dtype='category')
a.str.cat(b)
# Index(['aa', 'bb', 'aa'], dtype='object')
b.str.cat(a)
# AttributeError: Can only use .str accessor with string values (i.e. inferred_type is 'string', 'unicode' or 'mixed')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions