Skip to content

CLN: remove unused zip/enumerate/items #40699

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
Mar 31, 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
2 changes: 1 addition & 1 deletion pandas/core/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def normalize_keyword_aggregation(kwargs: dict) -> Tuple[dict, List[str], List[i
order = []
columns, pairs = list(zip(*kwargs.items()))

for name, (column, aggfunc) in zip(columns, pairs):
for column, aggfunc in pairs:
aggspec[column].append(aggfunc)
order.append((column, com.get_callable_name(aggfunc) or aggfunc))

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/groupby/grouper.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ def is_in_obj(gpr) -> bool:
# lambda here
return False

for i, (gpr, level) in enumerate(zip(keys, levels)):
for gpr, level in zip(keys, levels):

if is_in_obj(gpr): # df.groupby(df['name'])
in_axis, name = True, gpr.name
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2248,7 +2248,7 @@ def _convert_key(self, key, is_setter: bool = False):
"""
Require integer args. (and convert to label arguments)
"""
for a, i in zip(self.obj.axes, key):
for i in key:
if not is_integer(i):
raise ValueError("iAt based indexing can only have integer indexers")
return key
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/internals/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _iter_block_pairs(
# At this point we have already checked the parent DataFrames for
# assert rframe._indexed_same(lframe)

for n, blk in enumerate(left.blocks):
for blk in left.blocks:
locs = blk.mgr_locs
blk_vals = blk.values

Expand All @@ -40,7 +40,7 @@ def _iter_block_pairs(
# assert len(rblks) == 1, rblks
# assert rblks[0].shape[0] == 1, rblks[0].shape

for k, rblk in enumerate(rblks):
for rblk in rblks:
right_ea = rblk.values.ndim == 1

lvals, rvals = _get_same_shape_values(blk, rblk, left_ea, right_ea)
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/excel/_odfreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ def get_sheet_data(self, sheet, convert_float: bool) -> List[List[Scalar]]:

table: List[List[Scalar]] = []

for i, sheet_row in enumerate(sheet_rows):
for sheet_row in sheet_rows:
sheet_cells = [x for x in sheet_row.childNodes if x.qname in cell_names]
empty_cells = 0
table_row: List[Scalar] = []

for j, sheet_cell in enumerate(sheet_cells):
for sheet_cell in sheet_cells:
if sheet_cell.qname == table_cell_name:
value = self._get_cell_value(sheet_cell, convert_float)
else:
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/formats/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def build_tree(self) -> bytes:
f"{self.prefix_uri}{self.root_name}", attrib=self.other_namespaces()
)

for k, d in self.frame_dicts.items():
for d in self.frame_dicts.values():
self.d = d
self.elem_row = SubElement(self.root, f"{self.prefix_uri}{self.row_name}")

Expand Down Expand Up @@ -477,7 +477,7 @@ def build_tree(self) -> bytes:

self.root = Element(f"{self.prefix_uri}{self.root_name}", nsmap=self.namespaces)

for k, d in self.frame_dicts.items():
for d in self.frame_dicts.values():
self.d = d
self.elem_row = SubElement(self.root, f"{self.prefix_uri}{self.row_name}")

Expand Down
2 changes: 1 addition & 1 deletion pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -3540,7 +3540,7 @@ def validate_min_itemsize(self, min_itemsize):
return

q = self.queryables()
for k, v in min_itemsize.items():
for k in min_itemsize:

# ok, apply generally
if k == "values":
Expand Down
2 changes: 1 addition & 1 deletion pandas/plotting/_matplotlib/boxplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _validate_color_args(self):

if isinstance(self.color, dict):
valid_keys = ["boxes", "whiskers", "medians", "caps"]
for key, values in self.color.items():
for key in self.color:
if key not in valid_keys:
raise ValueError(
f"color dict contains invalid key '{key}'. "
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/constructors/test_from_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_from_records_dictlike(self):
# from the dict
blocks = df._to_dict_of_blocks()
columns = []
for dtype, b in blocks.items():
for b in blocks.values():
columns.extend(b.columns)

asdict = {x: y for x, y in df.items()}
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/frame/methods/test_to_dict_of_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_copy_blocks(self, float_frame):

# use the default copy=True, change a column
blocks = df._to_dict_of_blocks(copy=True)
for dtype, _df in blocks.items():
for _df in blocks.values():
if column in _df:
_df.loc[:, column] = _df[column] + 1

Expand All @@ -34,7 +34,7 @@ def test_no_copy_blocks(self, float_frame):

# use the copy=False, change a column
blocks = df._to_dict_of_blocks(copy=False)
for dtype, _df in blocks.items():
for _df in blocks.values():
if column in _df:
_df.loc[:, column] = _df[column] + 1

Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/plotting/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def test_finder_daily(self):
xpl1 = xpl2 = [Period("1999-1-1", freq="B").ordinal] * len(day_lst)
rs1 = []
rs2 = []
for i, n in enumerate(day_lst):
for n in day_lst:
rng = bdate_range("1999-1-1", periods=n)
ser = Series(np.random.randn(len(rng)), rng)
_, ax = self.plt.subplots()
Expand All @@ -439,7 +439,7 @@ def test_finder_quarterly(self):
xpl1 = xpl2 = [Period("1988Q1").ordinal] * len(yrs)
rs1 = []
rs2 = []
for i, n in enumerate(yrs):
for n in yrs:
rng = period_range("1987Q2", periods=int(n * 4), freq="Q")
ser = Series(np.random.randn(len(rng)), rng)
_, ax = self.plt.subplots()
Expand All @@ -461,7 +461,7 @@ def test_finder_monthly(self):
xpl1 = xpl2 = [Period("Jan 1988").ordinal] * len(yrs)
rs1 = []
rs2 = []
for i, n in enumerate(yrs):
for n in yrs:
rng = period_range("1987Q2", periods=int(n * 12), freq="M")
ser = Series(np.random.randn(len(rng)), rng)
_, ax = self.plt.subplots()
Expand Down Expand Up @@ -491,7 +491,7 @@ def test_finder_annual(self):
xp = [1987, 1988, 1990, 1990, 1995, 2020, 2070, 2170]
xp = [Period(x, freq="A").ordinal for x in xp]
rs = []
for i, nyears in enumerate([5, 10, 19, 49, 99, 199, 599, 1001]):
for nyears in [5, 10, 19, 49, 99, 199, 599, 1001]:
rng = period_range("1987", periods=nyears, freq="A")
ser = Series(np.random.randn(len(rng)), rng)
_, ax = self.plt.subplots()
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/scalar/period/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ def _ex(p):
return p.start_time + Timedelta(days=1, nanoseconds=-1)
return Timestamp((p + p.freq).start_time.value - 1)

for i, fcode in enumerate(from_lst):
for fcode in from_lst:
p = Period("1982", freq=fcode)
result = p.to_timestamp().to_period(fcode)
assert result == p
Expand Down
2 changes: 1 addition & 1 deletion scripts/validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def pandas_validate(func_name: str):
)

if doc.see_also:
for rel_name, rel_desc in doc.see_also.items():
for rel_name in doc.see_also:
if rel_name.startswith("pandas."):
result["errors"].append(
pandas_error(
Expand Down