Skip to content

API/BUG: Index.str.split(expand=True) not nan-safe #23677

Closed
@h-vetinari

Description

@h-vetinari

This is similar to #23558 and shares the same underlying reason: #23578
Found through extensive testing introduced in #23582 (which itself is a split off from #23167)

>>> values = ['a', np.nan, 'c']
>>> pd.Series(values).str.split(' ')
0    [a]
1    NaN
2    [c]
dtype: object
>>> pd.Series(values).str.split(' ', expand=True)
     0
0    a
1  NaN
2    c
>>> pd.Index(values).str.split(' ')
Index([['a'], nan, ['c']], dtype='object')
>>> pd.Index(values).str.split(' ', expand=True)
Traceback (most recent call last):
[...]
TypeError: object of type 'float' has no len()

Metadata

Metadata

Assignees

No one assigned

    Labels

    IndexingRelated to indexing on series/frames, not to indexes themselvesMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolateStringsString extension data type and string data

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions