Skip to content

Commit 7d2f5ce

Browse files
authoredMar 31, 2021
CLN: remove unused zip/enumerate/items (#40699)
1 parent 4fe34ef commit 7d2f5ce

File tree

13 files changed

+20
-20
lines changed

13 files changed

+20
-20
lines changed
 

‎pandas/core/aggregation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def normalize_keyword_aggregation(kwargs: dict) -> Tuple[dict, List[str], List[i
162162
order = []
163163
columns, pairs = list(zip(*kwargs.items()))
164164

165-
for name, (column, aggfunc) in zip(columns, pairs):
165+
for column, aggfunc in pairs:
166166
aggspec[column].append(aggfunc)
167167
order.append((column, com.get_callable_name(aggfunc) or aggfunc))
168168

‎pandas/core/groupby/grouper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ def is_in_obj(gpr) -> bool:
789789
# lambda here
790790
return False
791791

792-
for i, (gpr, level) in enumerate(zip(keys, levels)):
792+
for gpr, level in zip(keys, levels):
793793

794794
if is_in_obj(gpr): # df.groupby(df['name'])
795795
in_axis, name = True, gpr.name

‎pandas/core/indexing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2248,7 +2248,7 @@ def _convert_key(self, key, is_setter: bool = False):
22482248
"""
22492249
Require integer args. (and convert to label arguments)
22502250
"""
2251-
for a, i in zip(self.obj.axes, key):
2251+
for i in key:
22522252
if not is_integer(i):
22532253
raise ValueError("iAt based indexing can only have integer indexers")
22542254
return key

‎pandas/core/internals/ops.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def _iter_block_pairs(
2626
# At this point we have already checked the parent DataFrames for
2727
# assert rframe._indexed_same(lframe)
2828

29-
for n, blk in enumerate(left.blocks):
29+
for blk in left.blocks:
3030
locs = blk.mgr_locs
3131
blk_vals = blk.values
3232

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

43-
for k, rblk in enumerate(rblks):
43+
for rblk in rblks:
4444
right_ea = rblk.values.ndim == 1
4545

4646
lvals, rvals = _get_same_shape_values(blk, rblk, left_ea, right_ea)

‎pandas/io/excel/_odfreader.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ def get_sheet_data(self, sheet, convert_float: bool) -> List[List[Scalar]]:
101101

102102
table: List[List[Scalar]] = []
103103

104-
for i, sheet_row in enumerate(sheet_rows):
104+
for sheet_row in sheet_rows:
105105
sheet_cells = [x for x in sheet_row.childNodes if x.qname in cell_names]
106106
empty_cells = 0
107107
table_row: List[Scalar] = []
108108

109-
for j, sheet_cell in enumerate(sheet_cells):
109+
for sheet_cell in sheet_cells:
110110
if sheet_cell.qname == table_cell_name:
111111
value = self._get_cell_value(sheet_cell, convert_float)
112112
else:

‎pandas/io/formats/xml.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def build_tree(self) -> bytes:
307307
f"{self.prefix_uri}{self.root_name}", attrib=self.other_namespaces()
308308
)
309309

310-
for k, d in self.frame_dicts.items():
310+
for d in self.frame_dicts.values():
311311
self.d = d
312312
self.elem_row = SubElement(self.root, f"{self.prefix_uri}{self.row_name}")
313313

@@ -477,7 +477,7 @@ def build_tree(self) -> bytes:
477477

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

480-
for k, d in self.frame_dicts.items():
480+
for d in self.frame_dicts.values():
481481
self.d = d
482482
self.elem_row = SubElement(self.root, f"{self.prefix_uri}{self.row_name}")
483483

‎pandas/io/pytables.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3540,7 +3540,7 @@ def validate_min_itemsize(self, min_itemsize):
35403540
return
35413541

35423542
q = self.queryables()
3543-
for k, v in min_itemsize.items():
3543+
for k in min_itemsize:
35443544

35453545
# ok, apply generally
35463546
if k == "values":

‎pandas/plotting/_matplotlib/boxplot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def _validate_color_args(self):
8484

8585
if isinstance(self.color, dict):
8686
valid_keys = ["boxes", "whiskers", "medians", "caps"]
87-
for key, values in self.color.items():
87+
for key in self.color:
8888
if key not in valid_keys:
8989
raise ValueError(
9090
f"color dict contains invalid key '{key}'. "

‎pandas/tests/frame/constructors/test_from_records.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def test_from_records_dictlike(self):
149149
# from the dict
150150
blocks = df._to_dict_of_blocks()
151151
columns = []
152-
for dtype, b in blocks.items():
152+
for b in blocks.values():
153153
columns.extend(b.columns)
154154

155155
asdict = {x: y for x, y in df.items()}

‎pandas/tests/frame/methods/test_to_dict_of_blocks.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_copy_blocks(self, float_frame):
2020

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

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

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

‎pandas/tests/plotting/test_datetimelike.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def test_finder_daily(self):
417417
xpl1 = xpl2 = [Period("1999-1-1", freq="B").ordinal] * len(day_lst)
418418
rs1 = []
419419
rs2 = []
420-
for i, n in enumerate(day_lst):
420+
for n in day_lst:
421421
rng = bdate_range("1999-1-1", periods=n)
422422
ser = Series(np.random.randn(len(rng)), rng)
423423
_, ax = self.plt.subplots()
@@ -439,7 +439,7 @@ def test_finder_quarterly(self):
439439
xpl1 = xpl2 = [Period("1988Q1").ordinal] * len(yrs)
440440
rs1 = []
441441
rs2 = []
442-
for i, n in enumerate(yrs):
442+
for n in yrs:
443443
rng = period_range("1987Q2", periods=int(n * 4), freq="Q")
444444
ser = Series(np.random.randn(len(rng)), rng)
445445
_, ax = self.plt.subplots()
@@ -461,7 +461,7 @@ def test_finder_monthly(self):
461461
xpl1 = xpl2 = [Period("Jan 1988").ordinal] * len(yrs)
462462
rs1 = []
463463
rs2 = []
464-
for i, n in enumerate(yrs):
464+
for n in yrs:
465465
rng = period_range("1987Q2", periods=int(n * 12), freq="M")
466466
ser = Series(np.random.randn(len(rng)), rng)
467467
_, ax = self.plt.subplots()
@@ -491,7 +491,7 @@ def test_finder_annual(self):
491491
xp = [1987, 1988, 1990, 1990, 1995, 2020, 2070, 2170]
492492
xp = [Period(x, freq="A").ordinal for x in xp]
493493
rs = []
494-
for i, nyears in enumerate([5, 10, 19, 49, 99, 199, 599, 1001]):
494+
for nyears in [5, 10, 19, 49, 99, 199, 599, 1001]:
495495
rng = period_range("1987", periods=nyears, freq="A")
496496
ser = Series(np.random.randn(len(rng)), rng)
497497
_, ax = self.plt.subplots()

‎pandas/tests/scalar/period/test_period.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ def _ex(p):
646646
return p.start_time + Timedelta(days=1, nanoseconds=-1)
647647
return Timestamp((p + p.freq).start_time.value - 1)
648648

649-
for i, fcode in enumerate(from_lst):
649+
for fcode in from_lst:
650650
p = Period("1982", freq=fcode)
651651
result = p.to_timestamp().to_period(fcode)
652652
assert result == p

‎scripts/validate_docstrings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def pandas_validate(func_name: str):
223223
)
224224

225225
if doc.see_also:
226-
for rel_name, rel_desc in doc.see_also.items():
226+
for rel_name in doc.see_also:
227227
if rel_name.startswith("pandas."):
228228
result["errors"].append(
229229
pandas_error(

0 commit comments

Comments
 (0)
Please sign in to comment.