diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 5a97e1d5a04ea..09fa08339bd43 100644 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -1977,7 +1977,11 @@ def _setitem_single_column(self, loc: int, value, plane_indexer): # We will not operate in-place, but will attempt to in the future. # To determine whether we need to issue a FutureWarning, see if the # setting in-place would work, i.e. behavior will change. - warn = can_hold_element(orig_values, value) + if isinstance(value, ABCSeries): + warn = can_hold_element(orig_values, value._values) + else: + warn = can_hold_element(orig_values, value) + # Don't issue the warning yet, as we can still trim a few cases where # behavior will not change. diff --git a/pandas/tests/frame/indexing/test_setitem.py b/pandas/tests/frame/indexing/test_setitem.py index cf6d351aa78a0..a59d7d4f3bd45 100644 --- a/pandas/tests/frame/indexing/test_setitem.py +++ b/pandas/tests/frame/indexing/test_setitem.py @@ -683,6 +683,13 @@ def test_boolean_mask_nullable_int64(self): ) tm.assert_frame_equal(result, expected) + def test_setitem_ea_dtype_rhs_series(self): + # GH#47425 + df = DataFrame({"a": [1, 2]}) + df["a"] = Series([1, 2], dtype="Int64") + expected = DataFrame({"a": [1, 2]}, dtype="Int64") + tm.assert_frame_equal(df, expected) + # TODO(ArrayManager) set column with 2d column array, see #44788 @td.skip_array_manager_not_yet_implemented def test_setitem_npmatrix_2d(self):