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

ENH: Implement cum* methods for PyArrow strings #60633

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

rhshadrach
Copy link
Member

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Tests added and passed if fixing a bug or adding a new feature
  • All code checks passed.
  • Added type annotations to new arguments/methods/functions.
  • Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file if fixing a bug or adding a new feature.

Implements cumsum, cummin, and cummax for PyArrow-backed strings. I don't see a way to do this without passing through NumPy - if there are other ideas for approaching happy to give those a shot.

cc @WillAyd @jorisvandenbossche

@rhshadrach rhshadrach added Enhancement Strings String extension data type and string data Arrow pyarrow functionality Transformations e.g. cumsum, diff, rank labels Dec 31, 2024
@rhshadrach rhshadrach added this to the 2.3 milestone Dec 31, 2024
@WillAyd
Copy link
Member

WillAyd commented Dec 31, 2024

I don't see a way to do this without passing through NumPy - if there are other ideas for approaching happy to give those a shot.

The only other way I think that would be reasonable to implement this in would be to use nanoarrow, but that's a larger implementation. I think this is fine for now - just not very performant but that can always be improved later

@@ -163,10 +166,10 @@ def test_agg_cython_table_transform_series(request, series, func, expected):
# GH21224
# test transforming functions in
# pandas.core.base.SelectionMixin._cython_table (cumprod, cumsum)
if series.dtype == "string" and func == "cumsum":
if series.dtype == "string" and func == "cumsum" and not HAS_PYARROW:
Copy link
Member Author

Choose a reason for hiding this comment

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

Can tackle the StringArray case in a followup or do so here if preferred.

@rhshadrach rhshadrach requested a review from WillAyd January 4, 2025 15:36
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.

lgtm. thanks for getting this started

probably worth adding a note for 3.0 as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality Enhancement Strings String extension data type and string data Transformations e.g. cumsum, diff, rank
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants