diff --git a/python/cudf/cudf/api/types.py b/python/cudf/cudf/api/types.py index e94d3b504e8..a2afbde83eb 100644 --- a/python/cudf/cudf/api/types.py +++ b/python/cudf/cudf/api/types.py @@ -454,17 +454,23 @@ def is_any_real_numeric_dtype(arr_or_dtype) -> bool: # TODO: Evaluate which of the datetime types need special handling for cudf. is_datetime_dtype = _wrap_pandas_is_dtype_api(pd_types.is_datetime64_dtype) is_datetime64_any_dtype = pd_types.is_datetime64_any_dtype -is_datetime64_dtype = pd_types.is_datetime64_dtype -is_datetime64_ns_dtype = pd_types.is_datetime64_ns_dtype -is_datetime64tz_dtype = pd_types.is_datetime64tz_dtype +is_datetime64_dtype = _wrap_pandas_is_dtype_api(pd_types.is_datetime64_dtype) +is_datetime64_ns_dtype = _wrap_pandas_is_dtype_api( + pd_types.is_datetime64_ns_dtype +) +is_datetime64tz_dtype = _wrap_pandas_is_dtype_api( + pd_types.is_datetime64tz_dtype +) is_extension_type = pd_types.is_extension_type is_extension_array_dtype = pd_types.is_extension_array_dtype is_int64_dtype = pd_types.is_int64_dtype is_period_dtype = pd_types.is_period_dtype is_signed_integer_dtype = pd_types.is_signed_integer_dtype is_timedelta_dtype = _wrap_pandas_is_dtype_api(pd_types.is_timedelta64_dtype) -is_timedelta64_dtype = pd_types.is_timedelta64_dtype -is_timedelta64_ns_dtype = pd_types.is_timedelta64_ns_dtype +is_timedelta64_dtype = _wrap_pandas_is_dtype_api(pd_types.is_timedelta64_dtype) +is_timedelta64_ns_dtype = _wrap_pandas_is_dtype_api( + pd_types.is_timedelta64_ns_dtype +) is_unsigned_integer_dtype = pd_types.is_unsigned_integer_dtype is_sparse = pd_types.is_sparse # is_list_like = pd_types.is_list_like diff --git a/python/cudf/cudf/core/column/column.py b/python/cudf/cudf/core/column/column.py index 57f6c80fb05..53dbb9c50cc 100644 --- a/python/cudf/cudf/core/column/column.py +++ b/python/cudf/cudf/core/column/column.py @@ -53,6 +53,7 @@ infer_dtype, is_bool_dtype, is_categorical_dtype, + is_datetime64_dtype, is_datetime64tz_dtype, is_decimal32_dtype, is_decimal64_dtype, @@ -2230,6 +2231,12 @@ def as_column( data = ColumnBase.from_scalar(arbitrary, length if length else 1) elif isinstance(arbitrary, pd.core.arrays.masked.BaseMaskedArray): data = as_column(pa.Array.from_pandas(arbitrary), dtype=dtype) + elif isinstance(arbitrary, pd.DatetimeIndex) and isinstance( + arbitrary.dtype, pd.DatetimeTZDtype + ): + raise NotImplementedError( + "cuDF does not yet support timezone-aware datetimes" + ) else: try: data = as_column( @@ -2279,6 +2286,18 @@ def as_column( "Use `tz_localize()` to construct " "timezone aware data." ) + elif is_datetime64_dtype(dtype): + # Error checking only, actual construction happens + # below. + pa_array = pa.array(arbitrary) + if ( + isinstance(pa_array.type, pa.TimestampType) + and pa_array.type.tz is not None + ): + raise NotImplementedError( + "cuDF does not yet support timezone-aware " + "datetimes" + ) if is_list_dtype(dtype): data = pa.array(arbitrary) if type(data) not in (pa.ListArray, pa.NullArray): diff --git a/python/cudf/cudf/tests/test_datetime.py b/python/cudf/cudf/tests/test_datetime.py index 417df53c9c9..dcb8781e712 100644 --- a/python/cudf/cudf/tests/test_datetime.py +++ b/python/cudf/cudf/tests/test_datetime.py @@ -2093,6 +2093,8 @@ def test_construction_from_tz_timestamps(data): _ = cudf.Series(data) with pytest.raises(NotImplementedError): _ = cudf.Index(data) + with pytest.raises(NotImplementedError): + _ = cudf.DatetimeIndex(data) @pytest.mark.parametrize("op", _cmpops)