-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
TST: Test Loc to set Multiple Items to multiple new columns #42665
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
Changes from 4 commits
38d0502
85c554c
c93cbd6
4afc50b
98047f4
d44cdba
4f2a69c
d785568
e654ace
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2768,3 +2768,15 @@ def test_loc_setitem_dict_timedelta_multiple_set(self): | |
[[Timedelta(6, unit="s"), "foo"]], columns=["time", "value"], index=[1] | ||
) | ||
tm.assert_frame_equal(result, expected) | ||
|
||
def test_loc_set_multiple_items_in_multiple_new_columns(self): | ||
# GH 25594 | ||
df = DataFrame(index=[1, 2], columns=["a"]) | ||
df.loc[1, ["b", "c"]] = [6, 7] | ||
result = df.copy() | ||
|
||
expected = DataFrame(index=[1, 2], columns=["a", "b", "c"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please define expected without the use of loc. You can show the result of the sequential operations too, but please use another check for this |
||
expected.loc[1, "b"] = 6 | ||
expected.loc[1, "c"] = 7 | ||
|
||
tm.assert_frame_equal(result, expected, check_dtype=False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this fail w/o the check_dtype? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, as it should. The expected should have dtype object while df has dtype float in these columns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No result needed, just use df