Skip to content

Add removeprefix and removesuffix as StringMethods - #8912

Merged
jsignell merged 6 commits into
dask:mainfrom
jorloplaz:remove_prefix_or_suffix
Apr 18, 2022
Merged

jsignell merged 6 commits into
dask:mainfrom
jorloplaz:remove_prefix_or_suffix

Conversation

@jorloplaz

Copy link
Copy Markdown
Contributor

@GPUtester

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

jorge.lopez and others added 3 commits April 12, 2022 15:39
- Only support `removeprefix`/removesuffix` for pandas versions that
support it
- Use builtin `derived_from` support to error nicely if the pandas
version doesn't support it.
- Simplify tests
- Don't copy docstrings, ensure docs are built with pandas >= 1.14.0 to
include this new method.
@jcrist

jcrist commented Apr 13, 2022

Copy link
Copy Markdown
Member

Thanks @jorloplaz, I've pushed up a patch that simplifies the implementation. In general, we don't support methods that the user's installed version of pandas doesn't support (so no need to patch around if < 1.14). We can also rely on derived_from to error nicely for older versions of pandas, letting us avoid checking for existence of the method anywhere in the StringAccessor itself. I also simplified the test to make use of pytest.mark.parametrize.

@github-actions github-actions Bot added the documentation Improve or add to documentation label Apr 13, 2022
@jorloplaz

Copy link
Copy Markdown
Contributor Author

Thanks to you @jcrist , I wasn't sure that derived_from really enforced the version, and I didn't know either that the docs could be enforced to be built with one particular version. Just started contributing to Dask!

Just a comment: Pandas minimal version is 1.4.0, but you wrote 1.14 in the tuples. I guess you meant 1.4 there?

@jsignell

Copy link
Copy Markdown
Member

Pandas minimal version is 1.4.0, but you wrote 1.14 in the tuples. I guess you meant 1.4 there?

Good catch! I updated the test so that it would have caught that. And I update the version in the accessor as well :)

@jsignell

Copy link
Copy Markdown
Member

ok to test

@jsignell jsignell added the almost done Work is almost done! label Apr 15, 2022
@jsignell

Copy link
Copy Markdown
Member

Thanks @jorloplaz!!

@jsignell
jsignell merged commit 13f5b25 into dask:main Apr 18, 2022
@jorloplaz
jorloplaz deleted the remove_prefix_or_suffix branch August 3, 2022 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

almost done Work is almost done! dataframe documentation Improve or add to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add string methods removeprefix and removesuffix

4 participants