Skip to content

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

Closed
@jreback

Description

@jreback

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions