Skip to content

BUG: concat of all-nan with empty frame produces object dtype #9188

Closed
@jreback

Description

@jreback

xref #9149

The resultant has all missing and when concat with an empty frame should result in the same dtype (and not promotion)

In [1]: df_1 = pd.DataFrame({"Row":[0,1,1], "EmptyCol":np.nan, "NumberCol":[1,2,3]})

In [2]: df_2 = pd.DataFrame(columns = df_1.columns)

In [3]: df_concat = pd.concat([df_1, df_2], axis=0)

In [4]: df_1.dtypes
Out[4]: 
EmptyCol     float64
NumberCol      int64
Row            int64
dtype: object

In [6]: df_2.dtypes
Out[6]: 
EmptyCol     object
NumberCol    object
Row          object
dtype: object

In [7]: df_concat.dtypes
Out[7]: 
EmptyCol      object
NumberCol    float64
Row          float64
dtype: object

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions