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

BUG: CategoricalIndex.str.extractall fails #23555

Closed
h-vetinari opened this issue Nov 7, 2018 · 0 comments · Fixed by #24005
Closed

BUG: CategoricalIndex.str.extractall fails #23555

h-vetinari opened this issue Nov 7, 2018 · 0 comments · Fixed by #24005
Labels
Bug Categorical Categorical Data Type Indexing Related to indexing on series/frames, not to indexes themselves Strings String extension data type and string data
Milestone

Comments

@h-vetinari
Copy link
Contributor

h-vetinari commented Nov 7, 2018

Found a bug in a corner case while working on expanded test coverage in #23167:

>>> # the following three have the same result
>>> pd.Series(['a', 'b', 'aa'], dtype='category').str.extractall(r'(a)')
>>> pd.Series(['a', 'b', 'aa']).str.extractall(r'(a)')
>>> pd.Index(['a', 'b', 'aa']).str.extractall(r'(a)')
         0
  match
0 0      a
2 0      a
  1      a
>>> pd.Index(['a', 'b', 'aa'], dtype='category').str.extractall(r'(a)')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\ProgramData\Miniconda3\envs\pandas-dev\lib\site-packages\pandas\core\strings.py", line 2567, in extractall
    return str_extractall(self._orig, pat, flags=flags)
  File "C:\ProgramData\Miniconda3\envs\pandas-dev\lib\site-packages\pandas\core\strings.py", line 1012, in str_extractall
    is_mi = arr.index.nlevels > 1
AttributeError: 'CategoricalIndex' object has no attribute 'index'

So Series, categorical Series and Index work with extractall, but not CategoricalIndex.

@gfyoung gfyoung added Indexing Related to indexing on series/frames, not to indexes themselves Categorical Categorical Data Type Bug Strings String extension data type and string data labels Nov 8, 2018
@jreback jreback added this to the 0.24.0 milestone Dec 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Categorical Categorical Data Type Indexing Related to indexing on series/frames, not to indexes themselves Strings String extension data type and string data
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants