diff --git a/pandas/tests/frame/methods/test_update.py b/pandas/tests/frame/methods/test_update.py index f91238104ec89..81b25c0ad982e 100644 --- a/pandas/tests/frame/methods/test_update.py +++ b/pandas/tests/frame/methods/test_update.py @@ -197,6 +197,7 @@ def test_update_dt_column_with_NaT_create_column(self): np.datetime64("2000-01-02T00:00:00"), np.dtype("datetime64[ns]"), ), + (1, 2, pd.Int64Dtype()), ], ) def test_update_preserve_dtype(self, value_df, value_other, dtype): @@ -228,3 +229,19 @@ def test_update_on_duplicate_frame_unique_argument_index(self): expected = DataFrame({"a": [2, 2, 3]}, index=[1, 1, 2], dtype=np.dtype("intc")) df.update(other) tm.assert_frame_equal(df, expected) + + def test_update_preserve_mixed_dtypes(self): + # GH#44104 + dtype1 = pd.Int64Dtype() + dtype2 = pd.StringDtype() + df = DataFrame({"a": [1, 2, 3], "b": ["x", "y", "z"]}) + df = df.astype({"a": dtype1, "b": dtype2}) + + other = DataFrame({"a": [4, 5], "b": ["a", "b"]}) + other = other.astype({"a": dtype1, "b": dtype2}) + + expected = DataFrame({"a": [4, 5, 3], "b": ["a", "b", "z"]}) + expected = expected.astype({"a": dtype1, "b": dtype2}) + + df.update(other) + tm.assert_frame_equal(df, expected)