Skip to content

BUG: pd.array raising for large_string/large_binary with NumPy array #52590

Closed
@phofl

Description

@phofl

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

arr = np.array(["a", "b"])
pd.array(arr, dtype=pd.ArrowDtype(pa.large_string()))
arr = np.array([b"a", b"b"])
pd.array(arr, dtype=pd.ArrowDtype(pa.large_binary()))
Traceback (most recent call last):
  File "/Users/patrick/Library/Application Support/JetBrains/PyCharm2023.1/scratches/scratch.py", line 530, in <module>
    pd.array(arr, dtype=pd.ArrowDtype(pa.large_string()))
  File "/Users/patrick/PycharmProjects/pandas/pandas/core/construction.py", line 327, in array
    return cls._from_sequence(data, dtype=dtype, copy=copy)
  File "/Users/patrick/PycharmProjects/pandas/pandas/core/arrays/arrow/array.py", line 250, in _from_sequence
    scalars = pa.array(scalars, type=pa_dtype, from_pandas=True)
  File "pyarrow/array.pxi", line 316, in pyarrow.lib.array
  File "pyarrow/array.pxi", line 83, in pyarrow.lib._ndarray_to_array
  File "pyarrow/error.pxi", line 121, in pyarrow.lib.check_status
pyarrow.lib.ArrowNotImplementedError: NumPyConverter doesn't implement <large_string> conversion. 

Issue Description

This raises since NumPy does not implement the converter. I think we should work around this.

Expected Behavior

Returns an ArrowExtensionArray

Installed Versions

main

Metadata

Metadata

Assignees

No one assigned

    Labels

    Arrowpyarrow functionalityBug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions