diff --git a/doc/source/whatsnew/v2.1.0.rst b/doc/source/whatsnew/v2.1.0.rst index 7b9efd7f593dd..841b987c9b198 100644 --- a/doc/source/whatsnew/v2.1.0.rst +++ b/doc/source/whatsnew/v2.1.0.rst @@ -510,6 +510,7 @@ Sparse ExtensionArray ^^^^^^^^^^^^^^ +- Bug in :class:`DataFrame` constructor not copying :class:`Series` with extension dtype when given in dict (:issue:`53744`) - Bug in :class:`~arrays.ArrowExtensionArray` converting pandas non-nanosecond temporal objects from non-zero values to zero values (:issue:`53171`) - Bug in :meth:`Series.quantile` for pyarrow temporal types raising ArrowInvalid (:issue:`52678`) - Bug in :meth:`Series.rank` returning wrong order for small values with ``Float64`` dtype (:issue:`52471`) diff --git a/pandas/core/internals/construction.py b/pandas/core/internals/construction.py index dc9c47a4a5e34..7dcb33780dd08 100644 --- a/pandas/core/internals/construction.py +++ b/pandas/core/internals/construction.py @@ -469,7 +469,11 @@ def dict_to_mgr( x.copy() if isinstance(x, ExtensionArray) else x.copy(deep=True) - if isinstance(x, Index) + if ( + isinstance(x, Index) + or isinstance(x, ABCSeries) + and is_1d_only_ea_dtype(x.dtype) + ) else x for x in arrays ] diff --git a/pandas/tests/frame/test_constructors.py b/pandas/tests/frame/test_constructors.py index 06e244b93016c..3fbc6558b5c15 100644 --- a/pandas/tests/frame/test_constructors.py +++ b/pandas/tests/frame/test_constructors.py @@ -2576,6 +2576,13 @@ def check_views(c_only: bool = False): # TODO: we can check b[0] == 0 if we stop consolidating in # setitem_with_indexer (except for datetimelike?) + def test_construct_from_dict_ea_series(self): + # GH#53744 - default of copy=True should also apply for Series with + # extension dtype + ser = Series([1, 2, 3], dtype="Int64") + df = DataFrame({"a": ser}) + assert not np.shares_memory(ser.values._data, df["a"].values._data) + def test_from_series_with_name_with_columns(self): # GH 7893 result = DataFrame(Series(1, name="foo"), columns=["bar"])