-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
There was a problem hiding this 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
pandas/tests/test_strings.py
Outdated
@@ -1074,26 +1074,28 @@ def test_extractall_single_group_with_quantifier(self): | |||
|
|||
def test_extractall_no_matches(self): |
There was a problem hiding this comment.
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.
(['a3', 'b3', 'd4c2'], (None, 'i2')), | ||
(['a3', 'b3', 'd4c2'], ('i1', 'i2')), | ||
]) | ||
def test_extractall_no_matches(self, data, names): |
There was a problem hiding this comment.
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_
Ah, yes, sorry; didn't get this step. I've added it. |
There was a problem hiding this 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.
pandas/tests/test_strings.py
Outdated
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. |
There was a problem hiding this comment.
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
@jreback I've pushed the comment newline fix. |
thanks @jsnowacki |
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 inpandas.tests.test_strings
has been updated to reflect the expected result.