Skip to content

concat with Misaligned Column Labels and Extension Types loses Dtype #33027

Closed
@WillAyd

Description

@WillAyd

Was a little surprised by this behavior when combining frames with the string dtype and misaligned labels

In [2]: one = pd.DataFrame([["a"]], dtype="string", columns=["a"])
In [3]: two = pd.DataFrame([["b"]], dtype="string", columns=["b"])
In [4]: pd.concat([one, two]).dtypes
Out[4]:
a    object
b    object
dtype: object

A similar issue is exhibited with the integer types:

In [13]: one = pd.DataFrame([[1]], dtype="uint16", columns=["a"])
In [14]: two = pd.DataFrame([[2]], dtype="uint16", columns=["b"])
In [15]: pd.concat([one, two]).dtypes
Out[15]:
a    float64
b    float64
dtype: object

Occurs on master

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExtensionArrayExtending pandas with custom dtypes or arrays.ReshapingConcat, Merge/Join, Stack/Unstack, Explode

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions