Skip to content

REF: remove always-True DataFrame._iset_item kwarg #44587

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 2 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3914,9 +3914,9 @@ def _set_item_mgr(self, key, value: ArrayLike) -> None:
if len(self):
self._check_setitem_copy()

def _iset_item(self, loc: int, value, inplace: bool = False) -> None:
def _iset_item(self, loc: int, value) -> None:
arraylike = self._sanitize_column(value)
self._iset_item_mgr(loc, arraylike, inplace=inplace)
self._iset_item_mgr(loc, arraylike, inplace=True)

# check if we are modifying a copy
# try to set first as we want an invalid
Expand Down
16 changes: 6 additions & 10 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1871,11 +1871,11 @@ def _setitem_single_column(self, loc: int, value, plane_indexer):
# The setitem happened inplace, so the DataFrame's values
# were modified inplace.
return
self.obj._iset_item(loc, ser, inplace=True)
self.obj._iset_item(loc, ser)
return

# reset the sliced object if unique
self.obj._iset_item(loc, ser, inplace=True)
self.obj._iset_item(loc, ser)

def _setitem_single_block(self, indexer, value, name: str):
"""
Expand All @@ -1892,19 +1892,15 @@ def _setitem_single_block(self, indexer, value, name: str):
# set using those methods to avoid block-splitting
# logic here
if (
len(indexer) > info_axis
and is_integer(indexer[info_axis])
and all(
com.is_null_slice(idx)
for i, idx in enumerate(indexer)
if i != info_axis
)
self.ndim == len(indexer) == 2
and is_integer(indexer[1])
and com.is_null_slice(indexer[0])
):
col = item_labels[indexer[info_axis]]
if len(item_labels.get_indexer_for([col])) == 1:
# e.g. test_loc_setitem_empty_append_expands_rows
loc = item_labels.get_loc(col)
self.obj._iset_item(loc, value, inplace=True)
self.obj._iset_item(loc, value)
return

indexer = maybe_convert_ix(*indexer) # e.g. test_setitem_frame_align
Expand Down