Skip to content

Closes #5421: Support pandas Series and ArkoudaExtensionArray in GroupBy Reductions - #5422

Merged
ajpotts merged 1 commit into
Bears-R-Us:mainfrom
ajpotts:5421_NotImplementedError_pdarray_does_not_support_iteration_in_GroupBy.mean_for_ArkoudaExtensionArray
Feb 20, 2026
Merged

ajpotts merged 1 commit into
Bears-R-Us:mainfrom
ajpotts:5421_NotImplementedError_pdarray_does_not_support_iteration_in_GroupBy.mean_for_ArkoudaExtensionArray

Conversation

@ajpotts

@ajpotts ajpotts commented Feb 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR enhances arkouda.pandas.groupbyclass.GroupBy to accept:

  • pandas.Series backed by ArkoudaExtensionArray
  • ArkoudaExtensionArray directly
  • Existing pdarray inputs (unchanged behavior)

Previously, GroupBy.aggregate() and reduction helpers (e.g. mean,
sum, etc.) required a raw pdarray. Passing a pandas Series or
ArkoudaExtensionArray resulted in a TypeError.

This change introduces an internal helper _unwrap_to_pdarray() that
extracts the backing pdarray when a supported pandas container is
passed.


Motivation

When using the .ak accessor, users often construct groupby objects
from Arkouda-backed pandas structures. It is natural to expect:

gb.mean(pandas_series)

to behave the same as:

gb.mean(pdarray)

This PR removes unnecessary friction while preserving scalability and
avoiding any NumPy materialization.


Implementation Details

1. _unwrap_to_pdarray() helper

  • Accepts:
    • pdarray
    • pandas.Series backed by ArkoudaExtensionArray
    • ArkoudaExtensionArray
  • Returns:
    • The underlying Arkouda pdarray
  • Raises:
    • TypeError for unsupported inputs

2. Updated GroupBy.aggregate()

  • Calls _unwrap_to_pdarray() before performing segmented reductions.
  • Maintains existing behavior for all reduction operators.
  • Does not change server-side logic or Chapel implementation.

3. Typing Improvements

Expanded type annotations to reflect support for:

pdarray | pandas.Series | ArkoudaExtensionArray

Backward Compatibility

  • Fully backward compatible.
  • No behavior change for existing pdarray usage.
  • No API removal or signature breaking changes.

Tests Added

New tests verify:

  • GroupBy.mean() accepts a pandas Series backed by
    ArkoudaExtensionArray
  • GroupBy.mean() accepts an ArkoudaExtensionArray directly
  • Unsupported pandas Series raise TypeError
  • Raw pdarray behavior remains unchanged

Performance Impact

None.

The change is purely input normalization and does not affect: -
Segmented reduction logic - Server execution paths - Distributed
performance characteristics

All reductions still operate entirely on Arkouda server-side arrays.


Closes #5421: NotImplementedError: pdarray does not support iteration in GroupBy.mean for ArkoudaExtensionArray

@ajpotts
ajpotts force-pushed the 5421_NotImplementedError_pdarray_does_not_support_iteration_in_GroupBy.mean_for_ArkoudaExtensionArray branch from 2e46d33 to 80b6a29 Compare February 19, 2026 17:12
… iteration in GroupBy.mean for ArkoudaExtensionArray
@ajpotts
ajpotts force-pushed the 5421_NotImplementedError_pdarray_does_not_support_iteration_in_GroupBy.mean_for_ArkoudaExtensionArray branch from 80b6a29 to d32c0b8 Compare February 19, 2026 17:30
@ajpotts ajpotts changed the title Closes #5421: NotImplementedError: pdarray does not support iteration in GroupBy.mean for ArkoudaExtensionArray Closes #5421: Support pandas Series and ArkoudaExtensionArray in GroupBy Reductions Feb 19, 2026
@ajpotts
ajpotts marked this pull request as ready for review February 19, 2026 18:06
@ajpotts
ajpotts enabled auto-merge February 19, 2026 18:08

@jaketrookman jaketrookman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good

@ajpotts
ajpotts added this pull request to the merge queue Feb 20, 2026
Merged via the queue into Bears-R-Us:main with commit 2f4489e Feb 20, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support pandas Series and ArkoudaExtensionArray in GroupBy Reductions

2 participants