-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
DOC: specify regex=True in str.replace #41397
DOC: specify regex=True in str.replace #41397
Conversation
@rhshadrach If I'm understanding correctly, I think we would not want to skip this warning when a callable is passed, because that behavior will go from not raising to raising in the future. That way users who are implicitly relying on this won't be surprised when suddenly their code starts failing. It almost feels like the warning message could even be more verbose in this case. Not sure if we'd want to update this here too, but I just noticed the docstring for this method is grammatically a bit odd: pandas/pandas/core/strings/accessor.py Line 1234 in 67c9385
|
Thanks @dsaxton - I think that would not be the case if we followed my suggested way forward in the OP (and comment in the code, but perhaps that comment is too terse). Thoughts on this approach, where we would be ignoring the regex keyword when repl is callable?
I think this would be okay to address here, will do so. |
Ah, I misunderstood. Personally I like the idea of being consistent in how |
Makes sense @dsaxton - updated this PR to only fix documentation. |
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.
Thanks @rhshadrach, looks like an improvement to me
yep this lgtm. thanks @rhshadrach |
ref #36695
When passing a callable repl, str.replace will raise if regex is False. So it seems to me that in the future, when the default is changed, we should be ignoring the regex argument completely (and update the documentation to that effect). This is slightly magical, but I think better than having a default that raises.
If this is the correct way forward, then we don't need to warn when repl is callable.
cc @dsaxton @jorisvandenbossche