Skip to content

CLN: remove redundant variable in setitem_with_indexer #37563

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 1 commit into from
Nov 2, 2020
Merged
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
13 changes: 4 additions & 9 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1645,19 +1645,14 @@ def _setitem_with_indexer_split_path(self, indexer, value):
if isinstance(value, ABCSeries):
value = self._align_series(indexer, value)

info_idx = indexer[1]
if is_integer(info_idx):
info_idx = [info_idx]
labels = self.obj.columns[info_idx]

# Ensure we have something we can iterate over
ilocs = self._ensure_iterable_column_indexer(indexer[1])

plane_indexer = indexer[:1]
lplane_indexer = length_of_indexer(plane_indexer[0], self.obj.index)
# lplane_indexer gives the expected length of obj[indexer[0]]

if len(labels) == 1:
if len(ilocs) == 1:
# We can operate on a single column

# require that we are setting the right number of values that
Expand All @@ -1678,20 +1673,20 @@ def _setitem_with_indexer_split_path(self, indexer, value):
if isinstance(value, ABCDataFrame):
self._setitem_with_indexer_frame_value(indexer, value)

# we have an equal len ndarray/convertible to our labels
# we have an equal len ndarray/convertible to our ilocs
# hasattr first, to avoid coercing to ndarray without reason.
# But we may be relying on the ndarray coercion to check ndim.
# Why not just convert to an ndarray earlier on if needed?
elif np.ndim(value) == 2:
self._setitem_with_indexer_2d_value(indexer, value)

elif (
len(labels) == 1
len(ilocs) == 1
and lplane_indexer == len(value)
and not is_scalar(plane_indexer[0])
):
# we have an equal len list/ndarray
# We only get here with len(labels) == len(ilocs) == 1
# We only get here with len(ilocs) == 1
self._setitem_single_column(ilocs[0], value, plane_indexer)

elif lplane_indexer == 0 and len(value) == len(self.obj.index):
Expand Down