Skip to content

Indexing a row of a DataFrame with multiple ExtensionArrays coerces to object #22784

@TomAugspurger

Description

@TomAugspurger

Code Sample, a copy-pastable example if possible

In [8]: df = pd.DataFrame({"A": pd.Categorical([1, 2]), "B": pd.Categorical([1, 2])}) In [9]: df.loc[0] Out[9]: A 1 B 1 Name: 0, dtype: object

Problem description

The dtype is object. It should be category

Expected Output

A 1 B 1 Name: 0, dtype: category Categories (2, int64): [1, 2]

(for the release notes)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Dtype ConversionsUnexpected or buggy dtype conversionsExtensionArrayExtending 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