Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
WillAyd opened this issue Mar 25, 2020 · 0 comments · Fixed by #33522
Closed

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

WillAyd opened this issue Mar 25, 2020 · 0 comments · Fixed by #33522
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@WillAyd
Copy link
Member

WillAyd commented Mar 25, 2020

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

@WillAyd WillAyd added the ExtensionArray Extending pandas with custom dtypes or arrays. label Mar 25, 2020
TomAugspurger added a commit to TomAugspurger/pandas that referenced this issue Apr 13, 2020
@jreback jreback added this to the 1.1 milestone Apr 17, 2020
@jreback jreback added the Reshaping Concat, Merge/Join, Stack/Unstack, Explode label Apr 17, 2020
jreback pushed a commit that referenced this issue Jul 1, 2020
* BUG: Fixed concat with reindex and extension types

Closes #27692
Closes #33027

* rebase

* fixup

* cleanup

* fixups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants