API/BUG: Index.str.split(expand=True) not nan-safe · Issue #23677 · pandas-dev/pandas (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
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()