Skip to content

CLN: remove kwargs from signature of (Index|MultiIndex).copy #31669

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 2 commits into from
Feb 9, 2020
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
11 changes: 6 additions & 5 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,20 +823,22 @@ def repeat(self, repeats, axis=None):
# --------------------------------------------------------------------
# Copying Methods

def copy(self, name=None, deep=False, dtype=None, **kwargs):
def copy(self, name=None, deep=False, dtype=None, names=None):
"""
Make a copy of this object. Name and dtype sets those attributes on
the new object.

Parameters
----------
name : str, optional
name : Label
deep : bool, default False
dtype : numpy dtype or pandas type
dtype : numpy dtype or pandas type, optional
names : list-like, optional
Kept for compatibility with MultiIndex. Should not be used.

Returns
-------
copy : Index
Index

Notes
-----
Expand All @@ -848,7 +850,6 @@ def copy(self, name=None, deep=False, dtype=None, **kwargs):
else:
new_index = self._shallow_copy()

names = kwargs.get("names")
names = self._validate_names(name=name, names=names, deep=deep)
new_index = new_index.set_names(names)

Expand Down
10 changes: 5 additions & 5 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,8 +1000,8 @@ def copy(
levels=None,
codes=None,
deep=False,
name=None,
_set_identity=False,
**kwargs,
):
"""
Make a copy of this object. Names, dtype, levels and codes can be
Expand All @@ -1013,21 +1013,21 @@ def copy(
dtype : numpy dtype or pandas type, optional
levels : sequence, optional
codes : sequence, optional
deep : bool, default False
name : Label
Kept for compatibility with 1-dimensional Index. Should not be used.

Returns
-------
copy : MultiIndex
MultiIndex

Notes
-----
In most cases, there should be no functional difference from using
``deep``, but if ``deep`` is passed it will attempt to deepcopy.
This could be potentially expensive on large MultiIndex objects.
"""
name = kwargs.get("name")
names = self._validate_names(name=name, names=names, deep=deep)
if "labels" in kwargs:
raise TypeError("'labels' argument has been removed; use 'codes' instead")
if deep:
from copy import deepcopy

Expand Down