New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

str.cat inconsistent for CategoricalIndex #20842

Closed
h-vetinari opened this Issue Apr 27, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@h-vetinari
Contributor

h-vetinari commented Apr 27, 2018

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')
@WillAyd

This comment has been minimized.

Member

WillAyd commented Apr 30, 2018

Why wouldn't you just rename your categories?

@h-vetinari

This comment has been minimized.

Contributor

h-vetinari commented Apr 30, 2018

@WillAyd
this was just a toy example - if there's more to concatenate, it gets more unwieldy. But more than that, it makes no sense that a.str.cat(b) works, but b.str.cat(a) doesn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment