Skip to content

Commit dd28adb

Browse files
authored
BUG: Added test for setitem using loc not aligning on index (#59340)
* initial commit * Added test
1 parent 00cd5f1 commit dd28adb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/tests/indexing/test_loc.py

+8
Original file line numberDiff line numberDiff line change
@@ -3264,3 +3264,11 @@ def test_loc_nonunique_masked_index(self):
32643264
index=Index(np.array(ids).repeat(1000), dtype="Int64"),
32653265
)
32663266
tm.assert_frame_equal(result, expected)
3267+
3268+
def test_loc_index_alignment_for_series(self):
3269+
# GH #56024
3270+
df = DataFrame({"a": [1, 2], "b": [3, 4]})
3271+
other = Series([200, 999], index=[1, 0])
3272+
df.loc[:, "a"] = other
3273+
expected = DataFrame({"a": [999, 200], "b": [3, 4]})
3274+
tm.assert_frame_equal(expected, df)

0 commit comments

Comments
 (0)