Skip to content
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

sets in str.cat?! #23009

Closed
h-vetinari opened this issue Oct 5, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@h-vetinari
Copy link
Contributor

commented Oct 5, 2018

In #20347, I was asked to allow list-like inputs for the .str.cat methods for Series. However, I didn't know that is_listlike({'a', 'b', 'c'}) is True (for sets) until I stumbled over it in #22486.

These objects should imo clearly be disallowed, lest users shoot themselves in the foot massively:

>>> s = pd.Series(['a', 'b', 'c'])
>>> s.str.cat({'a', 'b', 'c'})
0    ac
1    bb
2    ca
dtype: object

I'm not even sure this should go through a deprecation cycle - IMO it's just a plain ol' bug that should be fixed ASAP.

@pambot

This comment has been minimized.

Copy link
Contributor

commented Oct 8, 2018

@h-vetinari There's definitely ways that this can misbehave, but the docstring for is_listlike shows using sets as an example, so it looks like it was intended?

@h-vetinari

This comment has been minimized.

Copy link
Contributor Author

commented Oct 8, 2018

@pambot
There was time pressure for #20347 before v0.23.0rc and a few things did not get fully discussed. Had I known that is_listlike(<set>) = True, I would have excluded it specifically.

In fact, I'm struggling to think of a use-case in pandas where the order is irrelevant - it's a different (and larger) discussion whether that aspect of is_listlike should maybe be changed, but it should definitely be changed for .str.cat

@h-vetinari h-vetinari referenced this issue Oct 16, 2018

Merged

BUG: sets in str.cat #23187

4 of 4 tasks complete

@jreback jreback added this to the 0.24.0 milestone Oct 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.