Skip to content

BUG: Series[python_str].__setitem__(series[pyarrow_string] #52987

@jbrockmendel

Description

@jbrockmendel
ser = pd.Series(range(5), dtype="string[python]")
ser2 = ser.astype("string[pyarrow]")


>>> ser[:2] = ser2[:2]
  File "pandas/core/arrays/string_.py", line 428, in __setitem__
    if len(value) and not lib.is_string_array(value, skipna=True):
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Argument 'values' has incorrect type (expected numpy.ndarray, got ArrowStringArray)

lib.is_string_array check in the traceback is preceded by

            if not is_array_like(value):
                value = np.asarray(value, dtype=object)
            if len(value) and not lib.is_string_array(value, skipna=True):

The is_array_like here is wrong. In this case we just need to convert to ndarray unconditionally.

Metadata

Metadata

Assignees

Labels

Arrowpyarrow functionalityBugNeeds TestsUnit test(s) needed to prevent regressionsStringsString extension data type and string datagood first issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions