Skip to content

Commit da0c63f

Browse files
jbrockmendelyeshsurya
authored andcommitted
CLN: reindex_axis remove unnecessary args, always copy=False (pandas-dev#41190)
1 parent ca6e0a4 commit da0c63f

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

pandas/core/generic.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,18 @@ def __init__(
246246

247247
@classmethod
248248
def _init_mgr(
249-
cls, mgr, axes, dtype: Dtype | None = None, copy: bool_t = False
249+
cls,
250+
mgr: Manager,
251+
axes,
252+
dtype: Dtype | None = None,
253+
copy: bool_t = False,
250254
) -> Manager:
251255
""" passed a manager and a axes dict """
252256
for a, axe in axes.items():
253257
if axe is not None:
254258
axe = ensure_index(axe)
255259
bm_axis = cls._get_block_manager_axis(a)
256-
mgr = mgr.reindex_axis(axe, axis=bm_axis, copy=False)
260+
mgr = mgr.reindex_axis(axe, axis=bm_axis)
257261

258262
# make a copy if explicitly requested
259263
if copy:

pandas/core/indexing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ def _ensure_listlike_indexer(self, key, axis=None, value=None):
701701
keys = self.obj.columns.union(key, sort=False)
702702

703703
self.obj._mgr = self.obj._mgr.reindex_axis(
704-
keys, axis=0, copy=False, consolidate=False, only_slice=True
704+
keys, axis=0, consolidate=False, only_slice=True
705705
)
706706

707707
def __setitem__(self, key, value):

pandas/core/internals/base.py

+8-15
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@
1111
from pandas._typing import (
1212
DtypeObj,
1313
Shape,
14+
final,
1415
)
1516
from pandas.errors import AbstractMethodError
1617

1718
from pandas.core.dtypes.cast import find_common_type
1819

1920
from pandas.core.base import PandasObject
20-
from pandas.core.indexes.api import (
21-
Index,
22-
ensure_index,
23-
)
21+
from pandas.core.indexes.api import Index
2422

2523
T = TypeVar("T", bound="DataManager")
2624

@@ -59,31 +57,26 @@ def reindex_indexer(
5957
) -> T:
6058
raise AbstractMethodError(self)
6159

60+
@final
6261
def reindex_axis(
63-
self,
64-
new_index,
62+
self: T,
63+
new_index: Index,
6564
axis: int,
66-
method=None,
67-
limit=None,
6865
fill_value=None,
69-
copy: bool = True,
7066
consolidate: bool = True,
7167
only_slice: bool = False,
72-
):
68+
) -> T:
7369
"""
7470
Conform data manager to new index.
7571
"""
76-
new_index = ensure_index(new_index)
77-
new_index, indexer = self.axes[axis].reindex(
78-
new_index, method=method, limit=limit
79-
)
72+
new_index, indexer = self.axes[axis].reindex(new_index)
8073

8174
return self.reindex_indexer(
8275
new_index,
8376
indexer,
8477
axis=axis,
8578
fill_value=fill_value,
86-
copy=copy,
79+
copy=False,
8780
consolidate=consolidate,
8881
only_slice=only_slice,
8982
)

0 commit comments

Comments
 (0)