diff --git a/doc/source/whatsnew/v1.6.0.rst b/doc/source/whatsnew/v1.6.0.rst index a7c9a7eb88221..a8baa6782d5a0 100644 --- a/doc/source/whatsnew/v1.6.0.rst +++ b/doc/source/whatsnew/v1.6.0.rst @@ -212,6 +212,7 @@ Sparse ExtensionArray ^^^^^^^^^^^^^^ - Bug in :meth:`Series.mean` overflowing unnecessarily with nullable integers (:issue:`48378`) +- Bug when concatenating an empty DataFrame with an ExtensionDtype to another DataFrame with the same ExtensionDtype, the resulting dtype turned into object (:issue:`48510`) - Styler diff --git a/pandas/tests/reshape/concat/test_empty.py b/pandas/tests/reshape/concat/test_empty.py index d78337131bb97..541a34bde8143 100644 --- a/pandas/tests/reshape/concat/test_empty.py +++ b/pandas/tests/reshape/concat/test_empty.py @@ -284,3 +284,11 @@ def test_concat_empty_dataframe_different_dtypes(self): result = concat([df1[:0], df2[:0]]) assert result["a"].dtype == np.int64 assert result["b"].dtype == np.object_ + + def test_concat_to_empty_ea(self): + """48510 `concat` to an empty EA should maintain type EA dtype.""" + df_empty = DataFrame({"a": pd.array([], dtype=pd.Int64Dtype())}) + df_new = DataFrame({"a": pd.array([1, 2, 3], dtype=pd.Int64Dtype())}) + expected = df_new.copy() + result = concat([df_empty, df_new]) + tm.assert_frame_equal(result, expected)