-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
DEPR: deprecate dtype param in Index.copy #35853
DEPR: deprecate dtype param in Index.copy #35853
Conversation
@@ -1030,7 +1030,6 @@ def _shallow_copy( | |||
name=lib.no_default, | |||
levels=None, | |||
codes=None, | |||
dtype=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other index types don't have dtype
param in their _shallow_copy
signature. Instead do dtype changing inside MultiIndex.copy
.
pandas/core/indexes/base.py
Outdated
@@ -820,6 +823,12 @@ def copy(self, name=None, deep=False, dtype=None, names=None): | |||
new_index = self._shallow_copy(name=name) | |||
|
|||
if dtype: | |||
warnings.warn( | |||
"parameter dtype is deprecated and will be removed in a future version." | |||
" Use the astype method instead.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like linter wants the whitespace in the previous line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, fixed.
d5be44c
to
a828666
Compare
thanks @topper-123 |
Deprecate
dtype
param inIndex.copy
and child methods. If users want to change dtype, they should useIndex.astype
.