Skip to content

[ENH] Add "fullmatch" matching mode to Series.str [#32806] #32807

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 13 commits into from
Mar 24, 2020

Conversation

frreiss
Copy link
Contributor

@frreiss frreiss commented Mar 18, 2020

This is my first PR against this project, so apologies if I've missed any steps in the process. I'm assuming that I'm supposed to fill in the checklist above myself.

This pull request adds the fullmatch regular expression matching mode to the other modes already present under the Series.str namespace. For example:

>>> s = pd.Series(["foo", "bar", "foobar"])
>>> s.str.fullmatch("foo")
0     True
1    False
2    False
dtype: bool

The fullmatch matching mode restricts matches to those that only match the entire string. Note the differences from match:

>>> s = pd.Series(["foo", "bar", "foobar"])
>>> s.str.fullmatch("foo")
0     True
1    False
2    False
dtype: bool
>>> s.str.match("foo")
0     True
1    False
2     True
dtype: bool

I've also added regression tests and a "what's new" entry.

I have also opened issue #32806 to cover this new feature.

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Thanks for the PR - looks pretty good! Just a few things

@WillAyd WillAyd added the Strings String extension data type and string data label Mar 18, 2020
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.

might need to update text.rst

@jreback jreback added this to the 1.1 milestone Mar 19, 2020
Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

minor nit on documentation but otherwise lgtm. @jreback

@frreiss
Copy link
Contributor Author

frreiss commented Mar 19, 2020

I'm currently rerunning CI tests locally after fixing that linter error. Sorry about that; I didn't know that black doesn't reorder imports for you.

@WillAyd
Copy link
Member

WillAyd commented Mar 19, 2020

Can you merge master one more time? Should resolve CI failure

@frreiss
Copy link
Contributor Author

frreiss commented Mar 20, 2020

Merged in changes from master; waiting for the next batch of CI results to come back.

@frreiss
Copy link
Contributor Author

frreiss commented Mar 24, 2020

Pushed some changes late last night that should address the remaining issues.

@jreback jreback merged commit bed9103 into pandas-dev:master Mar 24, 2020
@jreback
Copy link
Contributor

jreback commented Mar 24, 2020

thanks @frreiss very nice!

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

Successfully merging this pull request may close these issues.

ENH: Allow regex matching in fullmatch mode
3 participants