Repository navigation
Closes #4983: pandas dataframe accessor for arkouda - #5071
Merged
ajpotts merged 4 commits intoDec 8, 2025
Merged
Conversation
ajpotts
force-pushed
the
4983_pandas_dataframe_accessor_for_arkouda
branch
3 times, most recently
from
November 18, 2025 16:56
1a168a3 to
8b49c67
Compare
ajpotts
marked this pull request as ready for review
November 18, 2025 18:45
ajpotts
force-pushed
the
4983_pandas_dataframe_accessor_for_arkouda
branch
from
November 18, 2025 23:05
8b49c67 to
5edbc6f
Compare
ajpotts
marked this pull request as draft
November 19, 2025 14:09
ajpotts
force-pushed
the
4983_pandas_dataframe_accessor_for_arkouda
branch
3 times, most recently
from
November 19, 2025 17:27
772d566 to
f9d58a4
Compare
This was referenced Nov 26, 2025
ajpotts
force-pushed
the
4983_pandas_dataframe_accessor_for_arkouda
branch
2 times, most recently
from
December 2, 2025 17:57
4f7fc5e to
65dbd17
Compare
ajpotts
marked this pull request as ready for review
December 2, 2025 17:58
ajpotts
force-pushed
the
4983_pandas_dataframe_accessor_for_arkouda
branch
from
December 3, 2025 13:42
02cdf3b to
62b9fa5
Compare
drculhane
approved these changes
Dec 3, 2025
drculhane
left a comment
Contributor
There was a problem hiding this comment.
It looks like you have some rebase lines hanging out in tests/pandas/extension/arkouda_extension.py, starting at line 567. Other than that, this looks good.
ajpotts
force-pushed
the
4983_pandas_dataframe_accessor_for_arkouda
branch
from
December 5, 2025 12:27
94088f4 to
9eb7f5e
Compare
1RyanK
approved these changes
Dec 8, 2025
ajpotts
force-pushed
the
4983_pandas_dataframe_accessor_for_arkouda
branch
from
December 8, 2025 17:46
9eb7f5e to
f22fa04
Compare
1RyanK
approved these changes
Dec 8, 2025
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Dec 8, 2025
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Dec 17, 2025
# Add `.ak` Series Accessor & Improve EA Construction This PR introduces a new `.ak` accessor for `pandas.Series`, completing the pandas-side API for Arkouda-backed objects and bringing Series to parity with the existing Index/MultiIndex and DataFrame accessors. ## Summary of Changes ### 1. Add `ArkoudaSeriesAccessor` (`pd.Series.ak`) New module: `arkouda/pandas/extension/_series_accessor.py` This accessor enables seamless, zero-copy transitions between: - **NumPy-backed pandas Series** - **pandas Series backed by ArkoudaExtensionArray** (distributed / server-side) - **legacy Arkouda arrays** (`pdarray`, `Strings`, `Categorical`) Supported API: - `s.ak.to_ak()` – Convert a Series to an Arkouda-backed Series while preserving index and name - `s.ak.collect()` – Materialize an Arkouda-backed Series back to NumPy - `s.ak.to_ak_legacy()` – Produce the actual Arkouda array object - `pd.Series.ak.from_ak_legacy()` – Wrap a legacy Arkouda array in a Series without materializing - `s.ak.is_arkouda` – Introspection flag The implementation follows the same design, style, and semantics as the existing Index and DataFrame accessors. --- ### 2. Register accessor and expose it `ArkoudaSeriesAccessor` is now imported and exported from `arkouda.pandas.extension.__init__`, making it part of the public API. --- ### 3. Improve `ArkoudaExtensionArray._from_sequence` This new implementation adds a dtype-dispatching factory that: - Detects Arkouda server-side arrays (`pdarray`, `Strings`, `Categorical`) - Returns the correct EA subclass (`ArkoudaArray`, `ArkoudaStringArray`, `ArkoudaCategoricalArray`) - Falls back to converting Python/NumPy sequences into Arkouda `pdarray` (via `ak_array`) - Eliminates several circular import hazards with scoped local imports - Aligns behavior with pandas’ EA construction guidelines This method is required for correct Series construction and zero-copy wrapping in the accessor. --- ### 4. Add comprehensive unit tests New file: `tests/pandas/extension/series_accessor.py` Tests cover: - Doctest validation of the accessor module - Numeric and string roundtrip conversions - Preservation of index values and **index names** - `_pandas_series_to_ak_legacy` and `_ak_legacy_to_pandas_series` - Idempotency of `to_ak()` - Proper type dispatch (`Strings` vs `pdarray`) - Correct usage of ArkoudaExtensionArray These tests mirror the Index accessor test style to maintain consistency. --- ## Motivation Arkouda’s pandas integration already supports (PRs pending #5075 and #5071): - DataFrame `.ak` accessor - Index / MultiIndex `.ak` accessor - ExtensionArray subclasses Series was the missing piece. This PR completes the pandas API surface and unlocks: - Zero-copy Series-level conversions - Smooth DataFrame ↔ Series workflows - Easier construction of Arkouda-backed Series for testing and prototyping --- ## User-Facing Impact Users can now write: ```python >>> s = pd.Series([1, 2, 3]) >>> s_ak = s.ak.to_ak() >>> s_ak.ak.is_arkouda True ``` Closes #5087: pandas series accessor for arkouda --------- Co-authored-by: ajpotts <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR: Add ArkoudaDataFrameAccessor and End-to-End DataFrame Support in Pandas Extension API
This PR introduces full DataFrame-level support for Arkouda-backed pandas workflows, enabling zero-copy conversions, seamless merging, and rich interoperability between
pandas.DataFrameandarkouda.pandas.dataframe.DataFrame.Summary of Changes
🚀 New
ArkoudaDataFrameAccessor(df.ak)A new pandas DataFrame accessor is added:
This accessor provides:
df.ak.to_ak()— convert a pandas DataFrame to an Arkouda-backed pandas DataFrame (zero-copy-ish)df.ak.collect()— materialize Arkouda-backed columns to NumPy locallydf.ak.to_ak_legacy()— convert to legacyak.DataFramepd.DataFrame.ak.from_ak_legacy(akdf)— zero-copy conversion from legacy Arkouda DataFrame to pandasdf.ak.merge(...)— merge two Arkouda-backed pandas DataFrames using server-side Arkouda join🔄 Conversion Routines
Internal helpers implemented and tested:
_looks_like_ak_col_extract_ak_from_ea_is_arkouda_series_series_to_akcol_no_copy_df_to_akdf_no_copy_akdf_to_pandas_no_copyThese enable safe, zero-copy conversions in both directions.
🧪 Extensive Unit Tests
Added
tests/pandas/extension/dataframe_accessor.pycovering:inner,left,right,outer)Updated test discovery in
pytest.ini.Motivation
This PR completes the pandas ExtensionArray integration by providing first-class DataFrame operations. Prior to this work, users needed to manually convert via legacy
ak.DataFrameAPIs or operate at the Series/EA level. This PR removes that friction and enables:df.ak.merge(df2))Example Usage
Convert to Arkouda-backed pandas DataFrame
Merge using server-side Arkouda join
Convert a legacy ak.DataFrame to pandas (zero-copy)
Fully materialize back to NumPy
Closes #4983: pandas dataframe accessor for arkouda