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

[FEA] Support the case= argument to str.contains(...) #13253

Closed
shwina opened this issue Apr 30, 2023 · 1 comment · Fixed by #13290
Closed

[FEA] Support the case= argument to str.contains(...) #13253

shwina opened this issue Apr 30, 2023 · 1 comment · Fixed by #13290
Labels
feature request New feature or request good first issue Good for newcomers Python Affects Python cuDF API.

Comments

@shwina
Copy link
Contributor

shwina commented Apr 30, 2023

In Pandas .str.contains() function accepts a case= argument that ignores case when searching for substrings:

>>> s = pd.Series(['a', 'A', 'b'])
>>> s.str.contains('a')
0     True
1    False
2    False
dtype: bool
>>> s.str.contains('a', case=False)
0     True
1     True
2    False
dtype: bool

We don't currently support the case= argument, but I believe it can easily be supported by calling lower() (or alternatively upper()) on both the input string Series as well as the substring before the call to contains().

@shwina shwina added feature request New feature or request Python Affects Python cuDF API. labels Apr 30, 2023
@shwina shwina assigned shwina and unassigned shwina Apr 30, 2023
@shwina shwina added the good first issue Good for newcomers label Apr 30, 2023
@davidwendt
Copy link
Contributor

This approach likely work if regex=False. The description does not indicate the intention specifically.
Be careful here with the target input string since some regex character classes are different depending on the case of the flag. Specifically \d, \s, \w vs \D, \S, \W so changing the case on the regex pattern without accounting for those would give incorrect results. https://docs.rapids.ai/api/libcudf/stable/md_regex.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request good first issue Good for newcomers Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants