Skip to content

BUG: GH41044 - test loc dict assig #41076

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 21, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pandas/tests/indexing/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2700,3 +2700,13 @@ def test_loc_setitem(self, string_series):
string_series.loc[d2] = 6
assert string_series[d1] == 4
assert string_series[d2] == 6

def test_loc_dict_assign(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coudl you do something like test_loc_assign_dict_to_row. Maybe test would be better located in tests/frame/indexing but @jbrockmendel is the expert here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing. Let me know if it needs moving and I'll follow through. Still pretty knew to Pandas' testing structure 😅

# GH41044
dfo = DataFrame({"A": ["abc", "def"], "B": ["ghi", "jkl"]}, dtype="object")
dfs = DataFrame({"A": ["abc", "def"], "B": ["ghi", "jkl"]}, dtype="string")

dfo.loc[0, :] = {"A": "newA", "B": "newB"}
dfs.loc[0, :] = {"A": "newA", "B": "newB"}

tm.assert_frame_equal(dfo, dfs, check_dtype=False)