Skip to content

BUG: DataFrame([listlikes]) different shape if first listlike is Categorical #38845

Closed
@jbrockmendel

Description

@jbrockmendel
arrs =  [np.arange(0, 40, 10), np.arange(0, 40, 10), np.arange(0, 40, 10)]

arrs2 = arrs.copy()
arrs2[0] = pd.Categorical(arrs2[0])

df = pd.DataFrame(arrs)
df2 = pd.DataFrame(arrs2)
df3 = pd.DataFrame(arrs2[::-1])

>>> df.shape
(3, 4)
>>> df2.shape
(4, 3)
>>> df3.shape
(3, 4)

It's specific to Categorical, as we check isinstance(data[0], Categorical) in nested_data_to_arrays

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugCategoricalCategorical Data TypeConstructorsSeries/DataFrame/Index/pd.array ConstructorsNeeds DiscussionRequires discussion from core team before further action

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions