Skip to content

str.extractall with no match returns appropriate MultIndex #19075

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

Merged
merged 4 commits into from
Jan 5, 2018

Conversation

jsnowacki
Copy link
Contributor

Relates and fixes issue #19034. It's a small fix which creates empty MultiIndex instead of Index, with appropriate names, when str.extractall doesn't find any matches. Also, a related test in pandas.tests.test_strings has been updated to reflect the expected result.

@codecov
Copy link

codecov bot commented Jan 4, 2018

Codecov Report

Merging #19075 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #19075      +/-   ##
==========================================
- Coverage   91.51%   91.51%   -0.01%     
==========================================
  Files         148      148              
  Lines       48805    48688     -117     
==========================================
- Hits        44665    44555     -110     
+ Misses       4140     4133       -7
Flag Coverage Δ
#multiple 89.88% <100%> (-0.01%) ⬇️
#single 41.63% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/strings.py 98.46% <100%> (-0.01%) ⬇️
pandas/core/indexes/interval.py 92.19% <0%> (-0.43%) ⬇️
pandas/core/panel.py 96.83% <0%> (-0.01%) ⬇️
pandas/core/generic.py 95.9% <0%> (ø) ⬆️
pandas/tseries/offsets.py 96.97% <0%> (ø) ⬆️
pandas/core/dtypes/dtypes.py 95.31% <0%> (+0.03%) ⬆️
pandas/tseries/frequencies.py 95.9% <0%> (+1.99%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9303315...12f94de. Read the comment docs.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

tests comments & can you add a whatsnew for bug fixes

@@ -1074,26 +1074,28 @@ def test_extractall_single_group_with_quantifier(self):

def test_extractall_no_matches(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

can you parameterize this with both a 0-len index and a 0-len MI.

@jreback jreback added Bug MultiIndex Strings String extension data type and string data labels Jan 4, 2018
(['a3', 'b3', 'd4c2'], (None, 'i2')),
(['a3', 'b3', 'd4c2'], ('i1', 'i2')),
])
def test_extractall_no_matches(self, data, names):
Copy link
Contributor

Choose a reason for hiding this comment

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

By test comments, @jreback meant a comment with the issue number, so like # GH-19075 just below the def test_

@jsnowacki
Copy link
Contributor Author

Ah, yes, sorry; didn't get this step. I've added it.

@jreback jreback added this to the 0.23.0 milestone Jan 5, 2018
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

very minor comment. ping when pushed.

tm.assert_frame_equal(r, e)
# one named group.
r = s.str.extractall('(?P<first>z)')
e = DataFrame(columns=["first"])
e = DataFrame(columns=["first"], index=ei)
tm.assert_frame_equal(r, e)
# two named groups.
Copy link
Contributor

Choose a reason for hiding this comment

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

can you put a blank line before each comment; easier to read the tests then

@jsnowacki
Copy link
Contributor Author

@jreback I've pushed the comment newline fix.

@jreback
Copy link
Contributor

jreback commented Jan 5, 2018

thanks @jsnowacki

@jsnowacki jsnowacki deleted the fix_str_extractall_index branch January 5, 2018 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug MultiIndex Strings String extension data type and string data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants