Skip to content

BUG: DataFrame.where with EA other #38729

Closed
@jbrockmendel

Description

@jbrockmendel
df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
arr = pd.array([7, pd.NA, 9])
mask = np.ones(df.shape, dtype=bool)

>>> result = df.where(mask, arr)
AttributeError: 'IntegerArray' object has no attribute 'reshape'

we can kludge around this by using np.reshape(arr, shape) instead of arr.reshape(shape), but that'll cast to object, which is not great.

Non-kludge solution: 2D EAs

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugExtensionArrayExtending pandas with custom dtypes or arrays.IndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions