Skip to content

Commit

Permalink
TST: add test_update_raises_without_intersection on DataFrame (pandas…
Browse files Browse the repository at this point in the history
  • Loading branch information
aureliobarbosa committed Mar 1, 2024
1 parent a62684f commit 8a28fb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -8788,8 +8788,8 @@ def update(
rows = other.index.intersection(self.index)
if rows.empty:
raise ValueError(
"Update not allowed when other has no index in common with "
"this dataframe."
"Update not allowed when the index on `other` has no intersection "
"with this dataframe."
)

other = other.reindex(rows)
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/frame/methods/test_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@ def test_update_raises_on_duplicate_argument_index(self):
with pytest.raises(ValueError, match="duplicate index"):
df.update(other)

def test_update_raises_without_intersection(self):
# GH#55509
df = DataFrame({"a": [1]}, index=[1])
other = DataFrame({"a": [2]}, index=[2])
with pytest.raises(ValueError, match="no intersection"):
df.update(other)

def test_update_on_duplicate_frame_unique_argument_index(self):
# GH#55509
df = DataFrame({"a": [1, 1, 1]}, index=[1, 1, 2], dtype=np.dtype("intc"))
Expand Down

0 comments on commit 8a28fb0

Please sign in to comment.