Skip to content

Commit

Permalink
Align Index __init__ APIs with pandas 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke committed Jul 23, 2024
1 parent 3053f42 commit b6ce006
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
48 changes: 37 additions & 11 deletions python/cudf/cudf/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ class IndexMeta(type):
"""Custom metaclass for Index that overrides instance/subclass tests."""

def __call__(cls, data, *args, **kwargs):
if kwargs.get("tupleize_cols", True) is not True:
raise NotImplementedError(
"tupleize_cols is currently not supported."
)

if cls is Index:
return as_index(
arbitrary=data,
Expand Down Expand Up @@ -997,21 +1002,23 @@ def __dask_tokenize__(self):

class Index(SingleColumnFrame, BaseIndex, metaclass=IndexMeta):
"""
An array of orderable values that represent the indices of another Column
Immutable sequence used for indexing and alignment.
Attributes
----------
_values: A Column object
name: A string
The basic object storing axis labels for all pandas objects.
Parameters
----------
data : Column
The Column of data for this index
name : str optional
The name of the Index. If not provided, the Index adopts the value
Column's name. Otherwise if this name is different from the value
Column's, the data Column will be cloned to adopt this name.
data : array-like (1-dimensional)
dtype : str, numpy.dtype, or ExtensionDtype, optional
Data type for the output Index. If not specified, this will be
inferred from `data`.
copy : bool, default False
Copy input data.
name : object
Name to be stored in the index.
tupleize_cols : bool (default: True)
When True, attempt to create a MultiIndex if possible.
Currently not supported.
"""

@_performance_tracking
Expand Down Expand Up @@ -1735,8 +1742,18 @@ def __init__(
if tz is not None:
raise NotImplementedError("tz is not yet supported")
if normalize is not False:
warnings.warn(
"The 'normalize' keyword is "
"deprecated and will be removed in a future version. ",
FutureWarning,
)
raise NotImplementedError("normalize == True is not yet supported")
if closed is not None:
warnings.warn(
"The 'closed' keyword is "
"deprecated and will be removed in a future version. ",
FutureWarning,
)
raise NotImplementedError("closed is not yet supported")
if ambiguous != "raise":
raise NotImplementedError("ambiguous is not yet supported")
Expand Down Expand Up @@ -2480,6 +2497,14 @@ def __init__(
if freq is not None:
raise NotImplementedError("freq is not yet supported")

if closed is not None:
warnings.warn(
"The 'closed' keyword is "
"deprecated and will be removed in a future version. ",
FutureWarning,
)
raise NotImplementedError("closed is not yet supported")

if unit is not None:
warnings.warn(
"The 'unit' keyword is "
Expand Down Expand Up @@ -2863,6 +2888,7 @@ def __init__(
dtype=None,
copy: bool = False,
name=None,
verify_integrity: bool = True,
):
name = _getdefault_name(data, name=name)

Expand Down
2 changes: 1 addition & 1 deletion python/cudf/cudf/core/multiindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def __init__(
dtype=None,
copy=False,
name=None,
**kwargs,
verify_integrity=True,
):
if sortorder is not None:
raise NotImplementedError("sortorder is not yet supported")
Expand Down

0 comments on commit b6ce006

Please sign in to comment.