Repository navigation
Closes #4946: register extension dtypes - #5095
Merged
Merged
Conversation
Contributor
Author
Demo: Arkouda dtype aliases vs plain pandas dtypesYou can run this in an IPython session or Jupyter notebook. >>> import arkouda as ak
>>> ak.connect()
>>> import pandas as pd
>>> from arkouda.pandas.extension import (
... ArkoudaArray,
... ArkoudaStringArray,
... ArkoudaCategoricalArray,
... )
>>> from arkouda.pandas.extension._dtypes import (
... _ArkoudaBaseDtype,
... ArkoudaInt64Dtype,
... ArkoudaStringDtype,
... ArkoudaCategoricalDtype,
... )
# ---------------------------------------------------------------------
# 1. Plain pandas dtypes stay pure pandas (NO Arkouda involvement)
# ---------------------------------------------------------------------
>>> a_int = pd.array([1, 3, 4], dtype="int64")
>>> type(a_int)
pandas.core.arrays.numpy_.NumpyExtensionArray
>>> a_str = pd.array(["a", "b", "c"], dtype="string")
>>> type(a_str)
pandas.core.arrays.string_.StringArray
# Confirm they are not Arkouda-backed
>>> isinstance(a_int, ArkoudaArray), isinstance(a_str, ArkoudaArray)
(False, False)
# ---------------------------------------------------------------------
# 2. Arkouda-prefixed dtypes opt into Arkouda-backed arrays
# ---------------------------------------------------------------------
# Numeric example: ak.int64
>>> a_ak_int = pd.array([1, 3, 4], dtype="ak.int64")
>>> type(a_ak_int)
<class 'arkouda.pandas.extension._arkouda_array.ArkoudaArray'>
>>> a_ak_int.dtype
ArkoudaInt64Dtype('int64')
>>> isinstance(a_ak_int, ArkoudaArray)
True
# Demonstrate aliases
>>> _ArkoudaBaseDtype.construct_from_string("ak_int64")
ArkoudaInt64Dtype('int64')
>>> _ArkoudaBaseDtype.construct_from_string("akint64")
ArkoudaInt64Dtype('int64')
>>> _ArkoudaBaseDtype.construct_from_string("arkouda.int64")
ArkoudaInt64Dtype('int64')
# ---------------------------------------------------------------------
# 3. String and category use their specialized Arkouda EAs
# ---------------------------------------------------------------------
# String example
>>> a_ak_str = pd.array(["a", "b", "c"], dtype="ak.string")
>>> type(a_ak_str)
<class 'arkouda.pandas.extension._arkouda_string_array.ArkoudaStringArray'>
>>> a_ak_str.dtype
ArkoudaStringDtype('string')
>>> isinstance(a_ak_str, ArkoudaStringArray)
True
# Category example
>>> a_ak_cat = pd.array(["red", "blue", "red"], dtype="ak.category")
>>> type(a_ak_cat)
<class 'arkouda.pandas.extension._arkouda_categorical_array.ArkoudaCategoricalArray'>
>>> a_ak_cat.dtype
ArkoudaCategoricalDtype('category')
>>> isinstance(a_ak_cat, ArkoudaCategoricalArray)
True
# ---------------------------------------------------------------------
# 4. Plain "bigint" is not supported by pandas; Arkouda does not override
# ---------------------------------------------------------------------
>>> from pandas.errors import DataError
>>> import pytest
>>> try:
... pd.array([1, 3, 4], dtype="bigint")
... except TypeError as e:
... print("TypeError from pandas as expected:", e)
TypeError from pandas as expected: data type 'bigint' not understood
# But Arkouda-prefixed bigint works:
>>> a_ak_big = pd.array([1, 3, 4], dtype="ak.bigint")
>>> type(a_ak_big)
<class 'arkouda.pandas.extension._arkouda_array.ArkoudaArray'>
>>> a_ak_big.dtype
ArkoudaBigintDtype('bigint') |
ajpotts
marked this pull request as ready for review
December 1, 2025 21:44
1RyanK
approved these changes
Dec 5, 2025
1RyanK
left a comment
Contributor
There was a problem hiding this comment.
Looks good! Definitely do not have to address all of these.
ajpotts
force-pushed
the
4946_register_extension_dtypes
branch
from
December 8, 2025 15:22
028116f to
d9a73f4
Compare
1RyanK
approved these changes
Dec 8, 2025
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.
Improve dtype resolution & alias handling for Arkouda-backed pandas ExtensionArrays
This PR refines how Arkouda’s pandas integration handles dtype strings, expands alias support,
and strengthens correctness around when Arkouda arrays should (and should not) be constructed.
It also adds comprehensive test coverage across all Arkouda-supported dtypes.
🔧 Key Changes
1. Reworked
_ArkoudaBaseDtype.construct_from_stringak.int64,ak_int64,akint64,arkouda.int64"int64","float64","string","category", etc.)fall through to pandas’ native dtype resolution.
"ak.string"and"ak.category"so they map correctly toStringsand
Categorical.This makes Arkouda’s dtype resolution opt-in, removes ambiguity with built-in dtypes, and
aligns with user expectations when mixing Arkouda and pure pandas workflows.
2. Comprehensive test suite for dtype parsing and integration
This PR includes full test coverage for all Arkouda dtypes and dtype aliases.
✔ Dtype string → ArkoudaDtype resolution
TypeError, preventing Arkouda from overriding pandas behavior.✔
pd.arrayintegration across all typesArkoudaArray.ArkoudaStringArray.ArkoudaCategoricalArray.✔ Correct error behavior
dtype="bigint"remains unsupported by pandas and raisesTypeError.These tests provide end-to-end coverage for dtype resolution, array construction,
and pandas interop.
3. Clearer separation between Arkouda and native pandas behavior
This PR enforces:
ak.*orarkouda.*prefixesOverall, this significantly improves both user ergonomics and the robustness of the pandas
interoperability layer.
🧪 Summary of user-visible behavior after this PR
"int64""ak.int64"/"ak_int64"/ …"bool""ak.bool_"/"akbool"/ …"string""ak.string""category""ak.category""bigint"TypeError(pandas behavior)"ak.bigint"📈 Why this matters
including server-side BigInt ops, richer string operations, and improved categorical behavior.
✔ Ready for Review
This PR includes:
Please review and provide feedback!
Closes #4946: register extension dtypes