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

ENH/BUG: str.extractall doesn't support index #13156

Closed
wants to merge 1 commit into from

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented May 12, 2016

# same output as pd.Series(["a1a2", "b1", "c1"]).str.extractall("[ab](?P<digit>\d)")
idx = pd.Index(["a1a2", "b1", "c1"])
idx.str.extractall("[ab](?P<digit>\d)")
#         digit
#   match      
#0 0         1
#   1         2
#1 0         1

NOTE Also fixed a bug Series.str.extractall raises ValueError if its Index is str with 2 or more characters.

s = pd.Series(["a1a2", "b1", "c1"], index=pd.Index(["xx", "yy", "zz"]))
s.str.extractall("[ab](?P<digit>\d)")
# ValueError: Length of names must match number of levels in MultiIndex.

@sinhrks sinhrks added Bug Enhancement Strings String extension data type and string data labels May 12, 2016
@sinhrks sinhrks added this to the 0.18.2 milestone May 12, 2016
@sinhrks
Copy link
Member Author

sinhrks commented May 12, 2016

CC: @tdhock

@@ -313,6 +313,17 @@ then ``extractall(pat).xs(0, level='match')`` gives the same result as
extractall_result
extractall_result.xs(0, level="match")

``Index`` also supports ``.str.extractall``. It returns ``DataFrame`` which has the
same result as ``Series.str.extractall`` with default index (starts from 0).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a DataFrame

a Series.str.extractall

with a default index

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed these.

@jreback
Copy link
Contributor

jreback commented May 13, 2016

thanks @sinhrks very nice!

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

Successfully merging this pull request may close these issues.

ENH: Index StringMethods should return MultiIndex when result dimension is more than one
2 participants