Skip to content

BUG: DataFrame([Series with different CategoricalIndexes]) results in non-Categorical columns #57592

Open
@mroeschke

Description

@mroeschke
In [1]: import pandas as pd

In [4]: s1 = pd.Series([1, 2], index=pd.CategoricalIndex(["a", "b"]))

In [5]: s2 = pd.Series([3, 4], index=pd.CategoricalIndex(["a", "c"]))

In [6]: pd.DataFrame([s1, s2]).columns
Out[6]: Index(['a', 'b', 'c'], dtype='object')

I would have expected CategoricalIndex(['a', 'b', 'c'])

Metadata

Metadata

Assignees

No one assigned

    Labels

    CategoricalCategorical Data TypeConstructorsSeries/DataFrame/Index/pd.array ConstructorsDataFrameDataFrame data structure

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions