Skip to content
Open
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
26 changes: 16 additions & 10 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1524,7 +1524,7 @@ def iterrows(self) -> Iterable[tuple[Hashable, Series]]:
"""
columns = self.columns
klass = self._constructor_sliced
for k, v in zip(self.index, self.values):
for k, v in zip(self.index, self.values, strict=True):
s = klass(v, index=columns, name=k).__finalize__(self)
if self._mgr.is_single_block:
s._mgr.add_references(self._mgr)
Expand Down Expand Up @@ -1607,10 +1607,10 @@ def itertuples(
itertuple = collections.namedtuple( # type: ignore[misc]
name, fields, rename=True
)
return map(itertuple._make, zip(*arrays))
return map(itertuple._make, zip(*arrays, strict=True))

# fallback to regular tuples
return zip(*arrays)
return zip(*arrays, strict=True)

def __len__(self) -> int:
"""
Expand Down Expand Up @@ -4359,7 +4359,7 @@ def _setitem_array(self, key, value) -> None:

if isinstance(value, DataFrame):
check_key_length(self.columns, key, value)
for k1, k2 in zip(key, value.columns):
for k1, k2 in zip(key, value.columns, strict=False):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this one False?

self[k1] = value[k2]

elif not is_list_like(value):
Expand Down Expand Up @@ -4465,7 +4465,7 @@ def _set_item_frame_value(self, key, value: DataFrame) -> None:
if len(cols_droplevel) and not cols_droplevel.equals(value.columns):
value = value.reindex(cols_droplevel, axis=1)

for col, col_droplevel in zip(cols, cols_droplevel):
for col, col_droplevel in zip(cols, cols_droplevel, strict=True):
self[col] = value[col_droplevel]
return

Expand Down Expand Up @@ -6567,7 +6567,11 @@ class max type
names = self.index._get_default_index_names(names, default)

if isinstance(self.index, MultiIndex):
to_insert = zip(reversed(self.index.levels), reversed(self.index.codes))
to_insert = zip(
reversed(self.index.levels),
reversed(self.index.codes),
strict=True,
)
else:
to_insert = ((self.index, None),)

Expand Down Expand Up @@ -7093,7 +7097,7 @@ def f(vals) -> tuple[np.ndarray, int]:
result.name = None
else:
vals = (col.values for name, col in self.items() if name in subset)
labels, shape = map(list, zip(*map(f, vals)))
labels, shape = map(list, zip(*map(f, vals), strict=True))

ids = get_group_index(labels, tuple(shape), sort=False, xnull=False)
result = self._constructor_sliced(duplicated(ids, keep), index=self.index)
Expand Down Expand Up @@ -7346,7 +7350,9 @@ def sort_values(

# need to rewrap columns in Series to apply key function
if key is not None:
keys_data = [Series(k, name=name) for (k, name) in zip(keys, by)]
keys_data = [
Series(k, name=name) for (k, name) in zip(keys, by, strict=True)
]
else:
# error: Argument 1 to "list" has incompatible type
# "Generator[ExtensionArray | ndarray[Any, Any], None, None]";
Expand Down Expand Up @@ -8208,7 +8214,7 @@ def _dispatch_frame_op(

arrays = [
array_op(_left, _right)
for _left, _right in zip(self._iter_column_arrays(), right)
for _left, _right in zip(self._iter_column_arrays(), right, strict=True)
]

elif isinstance(right, Series):
Expand Down Expand Up @@ -11745,7 +11751,7 @@ def c(x):
return nanops.nancorr(x[0], x[1], method=method)

correl = self._constructor_sliced(
map(c, zip(left.values.T, right.values.T)),
map(c, zip(left.values.T, right.values.T, strict=True)),
index=left.columns,
copy=False,
)
Expand Down
Loading