Skip to content

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

Merged
merged 9 commits into from
Jul 28, 2021
9 changes: 9 additions & 0 deletions pandas/tests/indexing/test_loc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2768,3 +2768,12 @@ 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]

expected = DataFrame({"a": [np.nan, np.nan], "b": [6, np.nan], "c": [7, np.nan]}, index = [1, 2])

tm.assert_frame_equal(df, expected, check_dtype=False)
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the check_dtype=False parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@phofl I tried the remove the "check_dtype=False" parameter put the test is not passing. This is the error I'm getting: "- AssertionError: Attributes of DataFrame.iloc[:, 0] (column name="a") are different". I think the dtype of df and expected are different

Copy link
Member

Choose a reason for hiding this comment

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

Then you have to define expected accordingly