From b474dae8f31f16d61fb838990b2330d86a539756 Mon Sep 17 00:00:00 2001 From: "Korn, Uwe" Date: Sun, 15 Jul 2018 20:46:45 +0200 Subject: [PATCH] Concatenation of series of differing types should lead to object --- doc/source/whatsnew/v0.24.0.txt | 1 + pandas/core/dtypes/concat.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index 9e3f7ec73f852..a0966dcf8bdd9 100644 --- a/doc/source/whatsnew/v0.24.0.txt +++ b/doc/source/whatsnew/v0.24.0.txt @@ -257,6 +257,7 @@ ExtensionType Changes - Bug in :meth:`Series.get` for ``Series`` using ``ExtensionArray`` and integer index (:issue:`21257`) - :meth:`Series.combine()` works correctly with :class:`~pandas.api.extensions.ExtensionArray` inside of :class:`Series` (:issue:`20825`) - :meth:`Series.combine()` with scalar argument now works for any function type (:issue:`21248`) +- Bug in :func:`concat` that lead to inconsistent behaviour for ExtensionArrays where the scalar representation was int or float (:issue:`21792`) - .. _whatsnew_0240.api.incompatibilities: diff --git a/pandas/core/dtypes/concat.py b/pandas/core/dtypes/concat.py index 4a41b14cee071..9a5a775df6186 100644 --- a/pandas/core/dtypes/concat.py +++ b/pandas/core/dtypes/concat.py @@ -180,6 +180,8 @@ def is_nonempty(x): extensions = [is_extension_array_dtype(x) for x in to_concat] if any(extensions) and axis == 1: to_concat = [np.atleast_2d(x.astype('object')) for x in to_concat] + elif any(extensions): + to_concat = [x.astype('object') for x in to_concat] if not nonempty: # we have all empties, but may need to coerce the result dtype to