Skip to content

Commit a7fb88f

Browse files
authored
add test for setitem from duplicate axis (#34071)
* add test for setitem from duplicate axis * move test to tests/indexing/test_loc.py
1 parent 0ede947 commit a7fb88f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pandas/tests/indexing/test_loc.py

+13
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,19 @@ def test_loc_getitem_label_slice(self):
107107
"loc", slice(2, 4, 2), typs=["mixed"], axes=0, fails=TypeError,
108108
)
109109

110+
def test_setitem_from_duplicate_axis(self):
111+
# GH#34034
112+
df = DataFrame(
113+
[[20, "a"], [200, "a"], [200, "a"]],
114+
columns=["col1", "col2"],
115+
index=[10, 1, 1],
116+
)
117+
df.loc[1, "col1"] = np.arange(2)
118+
expected = DataFrame(
119+
[[20, "a"], [0, "a"], [1, "a"]], columns=["col1", "col2"], index=[10, 1, 1]
120+
)
121+
tm.assert_frame_equal(df, expected)
122+
110123

111124
class TestLoc2:
112125
# TODO: better name, just separating out things that rely on base class

0 commit comments

Comments
 (0)