Skip to content

Commit 2bfbc69

Browse files
committed
Test added for preserve mixed dtypes on update
1 parent 736702a commit 2bfbc69

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pandas/tests/frame/methods/test_update.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,19 @@ def test_update_on_duplicate_frame_unique_argument_index(self):
228228
expected = DataFrame({"a": [2, 2, 3]}, index=[1, 1, 2], dtype=np.dtype("intc"))
229229
df.update(other)
230230
tm.assert_frame_equal(df, expected)
231+
232+
def test_update_preserve_mixed_dtypes(self):
233+
# GH#44104
234+
dtype1 = pd.Int64Dtype()
235+
dtype2 = pd.StringDtype()
236+
df = pd.DataFrame({"a": [1, 2, 3], "b": ["x", "y", "z"]})
237+
df = df.astype({"a": dtype1, "b": dtype2})
238+
239+
other = pd.DataFrame({"a": [4, 5], "b": ["a", "b"]})
240+
other = other.astype({"a": dtype1, "b": dtype2})
241+
242+
expected = pd.DataFrame({"a": [4, 5, 3], "b": ["a", "b", "z"]})
243+
expected = expected.astype({"a": dtype1, "b": dtype2})
244+
245+
df.update(other)
246+
tm.assert_frame_equal(df, expected)

0 commit comments

Comments
 (0)