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

str.extractall with no matches has incorrect index. #19034

Closed
TomAugspurger opened this Issue Jan 2, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@TomAugspurger
Contributor

TomAugspurger commented Jan 2, 2018

Code Sample, a copy-pastable example if possible

In [26]: s = pd.Series(['a', 'ab', 'abc'])

In [27]: s.str.extractall("(A)")
Out[27]:
Empty DataFrame
Columns: [0]
Index: []

In [28]: s.iloc[:0].str.extractall("(a)")
Out[28]:
Empty DataFrame
Columns: [0]
Index: []

Problem description

From the docs:

Its rows have a MultiIndex with first levels that come from
the subject Series. The last level is named 'match' and indicates
the order in the subject.

So I think the correct index should be something like

 In [51]: pd.MultiIndex([[], []], [[], []], names=[None, 'match'])
Out[51]:
MultiIndex(levels=[[], []],
           labels=[[], []],
           names=[None, 'match'])

Expected Output

In [52]: pd.Series(index=pd.MultiIndex([[], []], [[], []], names=[None, 'match']))
Out[52]: Series([], dtype: float64)

xref dask/dask#3038

cc @tdhock

@jcrist

This comment has been minimized.

Contributor

jcrist commented Feb 6, 2018

I believe this was fixed in #19075 and can be closed.

@TomAugspurger

This comment has been minimized.

Contributor

TomAugspurger commented Feb 6, 2018

Yep, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment