Skip to content

Commit 03e1019

Browse files
authored
BUG: GH41044 - test loc dict assig (#41076)
1 parent bffed36 commit 03e1019

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pandas/tests/indexing/test_loc.py

+10
Original file line numberDiff line numberDiff line change
@@ -2700,3 +2700,13 @@ def test_loc_setitem(self, string_series):
27002700
string_series.loc[d2] = 6
27012701
assert string_series[d1] == 4
27022702
assert string_series[d2] == 6
2703+
2704+
@pytest.mark.parametrize("dtype", ["object", "string"])
2705+
def test_loc_assign_dict_to_row(self, dtype):
2706+
# GH41044
2707+
df = DataFrame({"A": ["abc", "def"], "B": ["ghi", "jkl"]}, dtype=dtype)
2708+
df.loc[0, :] = {"A": "newA", "B": "newB"}
2709+
2710+
expected = DataFrame({"A": ["newA", "def"], "B": ["newB", "jkl"]}, dtype=dtype)
2711+
2712+
tm.assert_frame_equal(df, expected)

0 commit comments

Comments
 (0)