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

API/ENH: str.split should return a DataFrame #8428

Closed
jreback opened this issue Sep 30, 2014 · 1 comment · Fixed by #8663
Closed

API/ENH: str.split should return a DataFrame #8428

jreback opened this issue Sep 30, 2014 · 1 comment · Fixed by #8663
Labels
API Design Enhancement Strings String extension data type and string data
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Sep 30, 2014

I find the behavior of str.split a bit odd, and it should by default just return a DataFrame (or maybe have a new function / option). Its straightforward to coerce it, but could/should be done internally.

(and str.extract does return a DataFrame IIRC)

In [22]: s
Out[22]: 
0            apple
1    apple, orange
2           orange
dtype: object

In [23]: s.str.split(',\s+')
Out[23]: 
0            [apple]
1    [apple, orange]
2           [orange]
dtype: object

In [24]: s.str.split(',\s+').apply(Series)
Out[24]: 
        0       1
0   apple     NaN
1   apple  orange
2  orange     NaN
@jreback jreback added Enhancement API Design Strings String extension data type and string data labels Sep 30, 2014
@jreback jreback added this to the 0.15.1 milestone Sep 30, 2014
@jorisvandenbossche
Copy link
Member

+1 I was also thinking that when reviewing the PR on the docs of this. But I think it should be an option for backwards compatibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Enhancement Strings String extension data type and string data
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants