BUG: concat of ExtensionBlock with different dtypes #29569
Labels
Bug
Duplicate Report
Duplicate issue or pull request
ExtensionArray
Extending pandas with custom dtypes or arrays.
Reshaping
Concat, Merge/Join, Stack/Unstack, Explode
Consider concatting two dataframes with both a column with an extension dtype, but with a different one (here string and nullable int):
This errors because in the concatenation, we have the following code:
pandas/pandas/core/internals/managers.py
Lines 2021 to 2024 in 5c36aa1
and the
is_uniform_join_units
only checks for ExtensionBlock, and not for the dtype of the block. Therefore, theExtensionBlock.concat_same_type
->ExtensionArray._concat_same_type
gets called assuming that all values are of the same dtype (which is not the case here, leading to the above error).The easy fix is to make
is_uniform_join_units
do a stricter check. But, we also need to decide on the alternative handling: how can some blocks still coerce? (eg Int64 and Int32 should result in Int64 ?)The text was updated successfully, but these errors were encountered: