Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7a72a06
Added test to check the dtype of the result of take method. Modified …
aijams Sep 29, 2025
65511cd
Added bug info to docs.
aijams Sep 29, 2025
42898c6
Added conditional to handle integer arrays in take method as special …
aijams Oct 2, 2025
333ba45
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 2, 2025
3ca2e84
Added cases for smaller integer types to mixins take function.
aijams Oct 6, 2025
b6e45ac
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 6, 2025
e0ff0d0
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 7, 2025
eeb3d85
Added note to take method.
aijams Oct 9, 2025
cd2f2aa
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 14, 2025
468de3f
Added link to issue in test for take method.
aijams Oct 15, 2025
91442a8
Moved changes to take method to NumpyExtensionArray class.
aijams Oct 16, 2025
aa3c228
Cleaned up work comments.
aijams Oct 16, 2025
8bacb94
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 16, 2025
56a329a
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 17, 2025
040c127
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 20, 2025
1bdb1f8
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 21, 2025
3e5836c
Tests for take method check against object dtype for boolean inputs.
aijams Oct 21, 2025
b4258f2
Removed TODO comment.
aijams Oct 21, 2025
e4c3a5b
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 22, 2025
acdfb62
Updated references to numpy.bool to include underscore.
aijams Oct 22, 2025
fd56024
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 23, 2025
8dcf8b2
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 28, 2025
f0886de
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Oct 29, 2025
c174833
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Nov 4, 2025
aa1c58b
Take method now gets underlying array of result to build a new extens…
aijams Nov 4, 2025
79c3116
Removed dtype preservation tests for take, except for boolean case.
aijams Nov 11, 2025
3edbc31
Merge remote-tracking branch 'upstream/main' into aijams-take-functio…
aijams Nov 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,7 @@ ExtensionArray
- Bug in :class:`Categorical` when constructing with an :class:`Index` with :class:`ArrowDtype` (:issue:`60563`)
- Bug in :meth:`.arrays.ArrowExtensionArray.__setitem__` which caused wrong behavior when using an integer array with repeated values as a key (:issue:`58530`)
- Bug in :meth:`ArrowExtensionArray.factorize` where NA values were dropped when input was dictionary-encoded even when dropna was set to False(:issue:`60567`)
- Bug in :meth:`NDArrayBackedExtensionArray.take` which produced arrays whose dtypes didn't match their underlying data, when called with integer arrays (:issue:`62448`)
- Bug in :meth:`api.types.is_datetime64_any_dtype` where a custom :class:`ExtensionDtype` would return ``False`` for array-likes (:issue:`57055`)
- Bug in comparison between object with :class:`ArrowDtype` and incompatible-dtyped (e.g. string vs bool) incorrectly raising instead of returning all-``False`` (for ``==``) or all-``True`` (for ``!=``) (:issue:`59505`)
- Bug in constructing pandas data structures when passing into ``dtype`` a string of the type followed by ``[pyarrow]`` while PyArrow is not installed would raise ``NameError`` rather than ``ImportError`` (:issue:`57928`)
Expand Down
12 changes: 12 additions & 0 deletions pandas/core/arrays/_mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from pandas.core.dtypes.dtypes import (
DatetimeTZDtype,
ExtensionDtype,
NumpyEADtype,
PeriodDtype,
)
from pandas.core.dtypes.missing import array_equivalent
Expand Down Expand Up @@ -173,6 +174,17 @@ def take(
fill_value=fill_value,
axis=axis,
)
if self.dtype in [
NumpyEADtype(np.uint8),
NumpyEADtype(np.uint16),
NumpyEADtype(np.uint32),
NumpyEADtype(np.uint64),
NumpyEADtype(np.int8),
NumpyEADtype(np.int16),
NumpyEADtype(np.int32),
NumpyEADtype(np.int64),
]:
return type(self)(new_data)
return self._from_backing_data(new_data)

# ------------------------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions pandas/tests/arrays/numpy_/test_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,15 @@ def test_factorize_unsigned():
tm.assert_extension_array_equal(res_unique, NumpyExtensionArray(exp_unique))


@pytest.mark.parametrize("dtype", [np.uint32, np.uint64, np.int32, np.int64])
def test_take_assigns_correct_dtype(dtype):
array = NumpyExtensionArray(np.array([1, 2, 3], dtype=dtype))

result = array.take([-1], allow_fill=True)

assert result.dtype == NumpyEADtype(np.float64)


# ----------------------------------------------------------------------------
# Output formatting

Expand Down
Loading