Skip to content

PandasArray.__setitem__ fails for strings #28118

Closed
@TomAugspurger

Description

@TomAugspurger
In [3]: t = pd.array(['a', 'b', 'c'])

In [4]: t[0] = 't'
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-7d1c8d6d2e6a> in <module>
----> 1 t[0] = 't'

~/sandbox/pandas/pandas/core/arrays/numpy_.py in __setitem__(self, key, value)
    237
    238         values = self._ndarray
--> 239         t = np.result_type(value, values)
    240         if t != self._ndarray.dtype:
    241             values = values.astype(t, casting="safe")

<__array_function__ internals> in result_type(*args, **kwargs)

TypeError: data type "t" not understood

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugExtensionArrayExtending pandas with custom dtypes or arrays.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions