Skip to content

Commit 350904c

Browse files
authored
REF: Use range over arange for iterators (#59619)
1 parent 45cafb5 commit 350904c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7051,7 +7051,7 @@ def fillna(
70517051
# see test_fillna_dict_inplace_nonunique_columns
70527052
locs = result.columns.get_loc(k)
70537053
if isinstance(locs, slice):
7054-
locs = np.arange(self.shape[1])[locs]
7054+
locs = range(self.shape[1])[locs]
70557055
elif isinstance(locs, np.ndarray) and locs.dtype.kind == "b":
70567056
locs = locs.nonzero()[0]
70577057
elif not (

pandas/core/indexing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2308,11 +2308,11 @@ def _ensure_iterable_column_indexer(self, column_indexer):
23082308
"""
23092309
Ensure that our column indexer is something that can be iterated over.
23102310
"""
2311-
ilocs: Sequence[int | np.integer] | np.ndarray
2311+
ilocs: Sequence[int | np.integer] | np.ndarray | range
23122312
if is_integer(column_indexer):
23132313
ilocs = [column_indexer]
23142314
elif isinstance(column_indexer, slice):
2315-
ilocs = np.arange(len(self.obj.columns))[column_indexer]
2315+
ilocs = range(len(self.obj.columns))[column_indexer]
23162316
elif (
23172317
isinstance(column_indexer, np.ndarray) and column_indexer.dtype.kind == "b"
23182318
):

0 commit comments

Comments
 (0)