Skip to content

DEPR: df.iloc[:, foo] = bar attempt to set inplace #45333

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 28 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9c8bafb
DEPR: df.iloc[:, foo] = bar attempt to set inplace
jbrockmendel Jan 12, 2022
67caa09
Merge branch 'main' into depr-isetitem
jbrockmendel Jan 16, 2022
d70cbdb
Merge branch 'main' into depr-isetitem
jbrockmendel Jan 17, 2022
ee4c0d2
doc fixup
jbrockmendel Jan 17, 2022
5102fbf
Merge branch 'main' into depr-isetitem
jbrockmendel Jan 19, 2022
48309bb
Merge branch 'main' into depr-isetitem
jbrockmendel Jan 19, 2022
ab87ef0
ArrayManager warnings
jbrockmendel Jan 19, 2022
65dddf2
Merge branch 'main' into depr-isetitem
jbrockmendel Jan 29, 2022
5ef3d38
merge main
jbrockmendel Feb 1, 2022
dcbf2f1
implement isetitem
jbrockmendel Feb 1, 2022
17c1efd
Merge branch 'main' into depr-isetitem
jbrockmendel Feb 5, 2022
5b05bab
Merge branch 'main' into depr-isetitem
jbrockmendel Feb 15, 2022
b8e9344
fix test
jbrockmendel Feb 15, 2022
f2b119f
whatsnew
jbrockmendel Feb 15, 2022
85449df
Merge branch 'main' into depr-isetitem
jbrockmendel Feb 16, 2022
048d777
Fix test for ArrayManager
jbrockmendel Feb 16, 2022
90d5150
Merge branch 'main' into depr-isetitem
jbrockmendel Feb 17, 2022
261a33a
Merge branch 'main' into depr-isetitem
jbrockmendel Feb 17, 2022
4d4ba5c
fix test with arrayManager
jbrockmendel Feb 17, 2022
5bf9a52
Merge branch 'main' into depr-isetitem
jbrockmendel Feb 28, 2022
2417c76
Merge branch 'main' into depr-isetitem
jbrockmendel Mar 1, 2022
8d9d9ff
Merge branch 'main' into depr-isetitem
jbrockmendel Mar 15, 2022
f549015
Merge branch 'main' into depr-isetitem
jbrockmendel Apr 11, 2022
eb2c98d
Merge branch 'main' into depr-isetitem
jbrockmendel May 2, 2022
709afde
Merge branch 'main' into depr-isetitem
jbrockmendel May 12, 2022
4e5c65d
empty commit to force CI
jbrockmendel May 13, 2022
d4332b7
Merge branch 'main' into depr-isetitem
jbrockmendel May 13, 2022
4d02c57
Merge branch 'main' into depr-isetitem
jbrockmendel May 23, 2022
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
Prev Previous commit
Next Next commit
implement isetitem
  • Loading branch information
jbrockmendel committed Feb 1, 2022
commit dcbf2f17c90a84f71159f23a08a9ab40313a84de
23 changes: 23 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3642,6 +3642,29 @@ def _get_value(self, index, col, takeable: bool = False) -> Scalar:
loc = engine.get_loc(index)
return series._values[loc]

def isetitem(self, loc, value) -> None:
"""
Set the given value in the column with position 'loc'.

This is a positional analogue to __setitem__.

Parameters
----------
loc : int or sequence of ints
value : scalar or arraylike

Notes
-----
Unlike `frame.iloc[:, i] = value`, `frame.isetitem(loc, value)` will
_never_ try to set the values in place, but will always insert a new
array.

In cases where `frame.columns` is unique, this is equivalent to
`frame[frame.columns[i]] = value`.
"""
arraylike = self._sanitize_column(value)
self._iset_item_mgr(loc, arraylike, inplace=False)

def __setitem__(self, key, value):
key = com.apply_if_callable(key, self)

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2010,7 +2010,7 @@ def _setitem_single_column(self, loc: int, value, plane_indexer):
"to set the values inplace instead of always setting a new "
"array. To retain the old behavior, use either "
"`df[df.columns[i]] = newvals` or, if columns are non-unique, "
"`df.iloc(axis=1)[i] = newvals`.",
"`df.isetitem(i, newvals)`",
FutureWarning,
stacklevel=find_stack_level(),
)
Expand Down