concat with Misaligned Column Labels and Extension Types loses Dtype · Issue #33027 · pandas-dev/pandas (original) (raw)
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