diff --git a/python/cudf/cudf/core/index.py b/python/cudf/cudf/core/index.py index 324db416be4..cd882aba297 100644 --- a/python/cudf/cudf/core/index.py +++ b/python/cudf/cudf/core/index.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018-2022, NVIDIA CORPORATION. +# Copyright (c) 2018-2023, NVIDIA CORPORATION. from __future__ import annotations @@ -313,9 +313,20 @@ def copy(self, name=None, deep=False, dtype=None, names=None): Ignored for RangeIndex dtype : numpy dtype optional (default: None) Target dtype for underlying range data + + .. deprecated:: 23.02 + + The `dtype` parameter is deprecated and will be removed in + a future version of cudf. Use the `astype` method instead. + names : list-like optional (default: False) Kept compatibility with MultiIndex. Should not be used. + .. deprecated:: 23.04 + + The parameter `names` is deprecated and will be removed in + a future version of cudf. Use the `name` parameter instead. + Returns ------- New RangeIndex instance with same range, casted to new dtype @@ -327,6 +338,13 @@ def copy(self, name=None, deep=False, dtype=None, names=None): FutureWarning, ) + if names is not None: + warnings.warn( + "parameter names is deprecated and will be removed in a " + "future version. Use the name parameter instead.", + FutureWarning, + ) + dtype = self.dtype if dtype is None else dtype if not np.issubdtype(dtype, np.signedinteger): @@ -1135,9 +1153,20 @@ def copy(self, name=None, deep=False, dtype=None, names=None): With ``deep=False`` the original data is used dtype : numpy dtype, default None Target datatype to cast into, use original dtype when None + + .. deprecated:: 23.02 + + The `dtype` parameter is deprecated and will be removed in + a future version of cudf. Use the `astype` method instead. + names : list-like, default False Kept compatibility with MultiIndex. Should not be used. + .. deprecated:: 23.04 + + The parameter `names` is deprecated and will be removed in + a future version of cudf. Use the `name` parameter instead. + Returns ------- New index instance, casted to new dtype @@ -1149,6 +1178,13 @@ def copy(self, name=None, deep=False, dtype=None, names=None): FutureWarning, ) + if names is not None: + warnings.warn( + "parameter names is deprecated and will be removed in a " + "future version. Use the name parameter instead.", + FutureWarning, + ) + dtype = self.dtype if dtype is None else dtype name = self.name if name is None else name diff --git a/python/cudf/cudf/core/multiindex.py b/python/cudf/cudf/core/multiindex.py index 783c3996400..573a3f7f1d7 100644 --- a/python/cudf/cudf/core/multiindex.py +++ b/python/cudf/cudf/core/multiindex.py @@ -336,11 +336,29 @@ def copy( Names for each of the index levels. dtype : object, optional (default None) MultiIndex dtype, only supports None or object type + + .. deprecated:: 23.02 + + The `dtype` parameter is deprecated and will be removed in + a future version of cudf. Use the `astype` method instead. + levels : sequence of arrays, optional (default None) The unique labels for each level. Original values used if None. + + .. deprecated:: 23.02 + + The `levels` parameter is deprecated and will be removed in + a future version of cudf. + codes : sequence of arrays, optional (default None) Integers for each level designating which label at each location. Original values used if None. + + .. deprecated:: 23.02 + + The `codes` parameter is deprecated and will be removed in + a future version of cudf. + deep : Bool (default False) If True, `._data`, `._levels`, `._codes` will be copied. Ignored if `levels` or `codes` are specified. @@ -401,6 +419,13 @@ def copy( FutureWarning, ) + if dtype is not None: + warnings.warn( + "parameter dtype is deprecated and will be removed in a " + "future version. Use the astype method instead.", + FutureWarning, + ) + dtype = object if dtype is None else dtype if not pd.core.dtypes.common.is_object_dtype(dtype): raise TypeError("Dtype for MultiIndex only supports object type.")