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 · Fixed by #23187
Closed

sets in str.cat?! #23009

h-vetinari opened this issue Oct 5, 2018 · 2 comments · Fixed by #23187
Labels
API Design Strings String extension data type and string data
Milestone

Comments

@h-vetinari
Copy link
Contributor

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
Copy link
Contributor

pambot 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
Copy link
Contributor Author

@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 mentioned this issue Oct 16, 2018
4 tasks
@jreback jreback added API Design Strings String extension data type and string data labels Oct 19, 2018
@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
Labels
API Design Strings String extension data type and string data
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants