diff --git a/python/cudf/cudf/core/index.py b/python/cudf/cudf/core/index.py index 96643ef08d3..fa7173f1d0f 100644 --- a/python/cudf/cudf/core/index.py +++ b/python/cudf/cudf/core/index.py @@ -2838,8 +2838,8 @@ def __init__( unit=None, freq=None, closed=None, - dtype="timedelta64[ns]", - copy=False, + dtype=None, + copy: bool = False, name=None, ): if freq is not None: @@ -2851,19 +2851,19 @@ def __init__( "dtype parameter is supported" ) - valid_dtypes = tuple( - f"timedelta64[{res}]" for res in ("s", "ms", "us", "ns") - ) - if dtype not in valid_dtypes: - raise TypeError("Invalid dtype") + if dtype is None: + dtype = "timedelta64[ns]" + dtype = cudf.dtype(dtype) + if dtype.kind != "m": + raise TypeError("dtype must be a timedelta type") - kwargs = _setdefault_name(data, name=name) + name = _setdefault_name(data, name=name)["name"] data = column.as_column(data, dtype=dtype) if copy: data = data.copy() - super().__init__(data, **kwargs) + super().__init__(data, name=name) def __getitem__(self, index): value = super().__getitem__(index)