Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Simplify other expected messages
  • Loading branch information
mroeschke committed Feb 5, 2024
commit 3afe80274bd8fe7420d85e4382ca0c47cf3b7da4
16 changes: 2 additions & 14 deletions pandas/tests/indexing/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,13 +1224,7 @@ def test_loc_setitem_empty_append_raises(self):
with pytest.raises(KeyError, match=msg):
df.loc[[0, 1], "x"] = data

msg = "|".join(
[
"cannot copy sequence with size 2 to array axis with dimension 0",
r"could not broadcast input array from shape \(2,\) into shape \(0,\)",
"Must have equal len keys and value when setting with an iterable",
]
)
msg = "setting an array element with a sequence."
with pytest.raises(ValueError, match=msg):
df.loc[0:2, "x"] = data

Expand Down Expand Up @@ -1556,16 +1550,10 @@ def test_loc_setitem_2d_to_1d_raises(self):
# float64 dtype to avoid upcast when trying to set float data
ser = Series(range(2), dtype="float64")

msg = "|".join(
[
r"shape mismatch: value array of shape \(2,2\)",
r"cannot reshape array of size 4 into shape \(2,\)",
]
)
msg = "setting an array element with a sequence."
with pytest.raises(ValueError, match=msg):
ser.loc[range(2)] = data

msg = r"could not broadcast input array from shape \(2,2\) into shape \(2,?\)"
with pytest.raises(ValueError, match=msg):
ser.loc[:] = data

Expand Down