-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
test: Add test for loc assignment changes datetime dtype #50037
test: Add test for loc assignment changes datetime dtype #50037
Conversation
alonme
commented
Dec 3, 2022
•
edited
Loading
edited
- closes BUG: Assignment to a .loc view of a naive datetime column changes its dtype to object #49837
- All code checks passed.
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.
Looks good to me, thanks @alonme
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.
small comments
pandas/tests/indexing/test_loc.py
Outdated
expected = df.copy(deep=True) | ||
|
||
update_df = df[df["update"]] | ||
df.loc[df["update"], ["date"]] = update_df["date"] |
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.
Can you test for df.loc[df["update"], ["date"]]
and df.loc[df["update"], "date"]
? This takes significantly different code paths.
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.
yup, actually the bug didn't occur in the second one.
will add.
BTW - is this the right place for the test?
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.
good point, better place is probably frame/indexing/test_indexing
788cd14
to
ba9b41d
Compare
@phofl ping |
@@ -1454,6 +1455,32 @@ def test_loc_bool_multiindex(self, dtype, indexer): | |||
) | |||
tm.assert_frame_equal(result, expected) | |||
|
|||
@pytest.mark.parametrize("utc", [False, True]) | |||
@pytest.mark.parametrize("column_label_array", [False, True]) |
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.
You can do @pytest.mark.parametrize("indexer", ["date", ["date]])
, then you don't need if on your test
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.
fixed
thx @alonme |