Skip to content

WARN: Remove false positive warning for iloc inplaceness #48397

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 22 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
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
Next Next commit
WARN: Remove false positive warning for iloc inplaceness
  • Loading branch information
phofl committed Sep 5, 2022
commit 8f7432b1cc7791c2ccbb003aa4206c24476b333d
3 changes: 3 additions & 0 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
is_array_like,
is_bool_dtype,
is_extension_array_dtype,
is_float_dtype,
is_hashable,
is_integer,
is_iterator,
Expand Down Expand Up @@ -2016,6 +2017,8 @@ def _setitem_single_column(self, loc: int, value, plane_indexer):
and (
np.shares_memory(new_values, orig_values)
or new_values.shape != orig_values.shape
or not is_float_dtype(orig_values)
and isna(new_values).any()
)
):
# TODO: get something like tm.shares_memory working?
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/frame/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,8 @@ def test_loc_expand_empty_frame_keep_midx_names(self):
def test_loc_setitem_rhs_frame(self, idxr, val):
# GH#47578
df = DataFrame({"a": [1, 2]})
df.loc[:, "a"] = DataFrame({"a": [val, 11]}, index=[1, 2])
with tm.assert_produces_warning(None):
df.loc[:, idxr] = DataFrame({"a": [val, 11]}, index=[1, 2])
expected = DataFrame({"a": [np.nan, val]})
tm.assert_frame_equal(df, expected)

Expand Down