-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH: add string method remove prefix and suffix, python 3.9 #36944
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
Comments
+1 @erfannariman Your alternative to |
True, but you could solve that with: |
@erfannariman, your updated version won't work if the prefix is not separated by a delimiter. e.g. for prefix The most robust method is the one documented in PEP 616. e.g. prefix = 'str'
df2 = df.copy()
df2.loc[df['A'].str.startswith(prefix), 'A'] = df2.loc[df['A'].str.startswith(prefix), 'A'].str[len(prefix):]
df2 I think this makes a pretty good case that it would be nice to add the new string methods! |
Yes, I agree. |
+1 in adding this |
@simonjayhawkins Would this be a good first issue? Happy to help in that case. |
Thanks @janosh. sure. go for it! |
Great. Anything to be aware of? Is it okay to use |
From the comments here and the stalled PR #39226, I believe that we would want to use the implementation in PEP 616 to order to provide support for Python <3.9. I think there is an outstanding question on whether we use the python native functions when available #39226 (comment). |
Cool, I opened a draft PR at #43328. Let's discuss details there. |
Opening this issue for discussion:
Since python 3.9 is out, and we have the new string methods
removeprefix
andremovesuffix
, it would be nice to add them to the pandas string methods as wellAn argument not to add this is that it's pretty easily to achieve with
str.split
:The text was updated successfully, but these errors were encountered: