Skip to content

BUG: pd.api.extensions.take does not accept NumpyExtensionArray #59177

@andrewgsavage

Description

@andrewgsavage

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd 
import numpy as np

arr = pd.arrays.NumpyExtensionArray(np.array([1,2,3]))
pd.api.extensions.take(arr,[2])

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\mambaforge\envs\test_py300\Lib\site-packages\pandas\core\algorithms.py", line 1166, in take
    raise TypeError(
TypeError: pd.api.extensions.take requires a numpy.ndarray, ExtensionArray, Index, or Series, got NumpyExtensionArray.

Issue Description

I'd expect NumpyExtensionArray to be considered an ExtensionArray, so compatable with pd.api.extensions.take.

Expected Behavior

return

<NumpyExtensionArray>
[2]
Length: 1, dtype: int32

Installed Versions

Replace this line with the output of pd.show_versions()

Metadata

Metadata

Assignees

Labels

AlgosNon-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diffBug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions