Skip to content

Commit 86871c1

Browse files
committed
CLN: clean signature of (Index|MultiIndex).copy
1 parent 0bfb8cb commit 86871c1

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

pandas/core/indexes/base.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -823,20 +823,22 @@ def repeat(self, repeats, axis=None):
823823
# --------------------------------------------------------------------
824824
# Copying Methods
825825

826-
def copy(self, name=None, deep=False, dtype=None, **kwargs):
826+
def copy(self, name=None, deep=False, dtype=None, names=None):
827827
"""
828828
Make a copy of this object. Name and dtype sets those attributes on
829829
the new object.
830830
831831
Parameters
832832
----------
833-
name : str, optional
833+
name : Optional[Hashable]
834834
deep : bool, default False
835-
dtype : numpy dtype or pandas type
835+
dtype : numpy dtype or pandas type, optional
836+
names : list-like, optional
837+
Kept for compatibility with MultiIndex. Should not be used.
836838
837839
Returns
838840
-------
839-
copy : Index
841+
Index
840842
841843
Notes
842844
-----
@@ -848,7 +850,6 @@ def copy(self, name=None, deep=False, dtype=None, **kwargs):
848850
else:
849851
new_index = self._shallow_copy()
850852

851-
names = kwargs.get("names")
852853
names = self._validate_names(name=name, names=names, deep=deep)
853854
new_index = new_index.set_names(names)
854855

pandas/core/indexes/multi.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1000,8 +1000,8 @@ def copy(
10001000
levels=None,
10011001
codes=None,
10021002
deep=False,
1003+
name=None,
10031004
_set_identity=False,
1004-
**kwargs,
10051005
):
10061006
"""
10071007
Make a copy of this object. Names, dtype, levels and codes can be
@@ -1013,21 +1013,21 @@ def copy(
10131013
dtype : numpy dtype or pandas type, optional
10141014
levels : sequence, optional
10151015
codes : sequence, optional
1016+
deep : bool, default False
1017+
name : Optional[Hashable]
1018+
Kept for compatibility with 1-dimensional Index. Should not be used.
10161019
10171020
Returns
10181021
-------
1019-
copy : MultiIndex
1022+
MultiIndex
10201023
10211024
Notes
10221025
-----
10231026
In most cases, there should be no functional difference from using
10241027
``deep``, but if ``deep`` is passed it will attempt to deepcopy.
10251028
This could be potentially expensive on large MultiIndex objects.
10261029
"""
1027-
name = kwargs.get("name")
10281030
names = self._validate_names(name=name, names=names, deep=deep)
1029-
if "labels" in kwargs:
1030-
raise TypeError("'labels' argument has been removed; use 'codes' instead")
10311031
if deep:
10321032
from copy import deepcopy
10331033

0 commit comments

Comments
 (0)