Skip to content

Commit

Permalink
Handle timezones in dtype conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
vyasr committed Nov 29, 2023
1 parent 83c2630 commit ce381e1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions python/cudf/cudf/_lib/types.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from enum import IntEnum

import numpy as np
import pandas as pd

from libcpp.memory cimport make_shared, shared_ptr

Expand Down Expand Up @@ -270,9 +271,13 @@ cpdef dtype_to_pylibcudf_type(dtype):
else:
tid = pylibcudf.TypeId.DECIMAL32
return pylibcudf.DataType(tid, -dtype.scale)
return pylibcudf.DataType(
SUPPORTED_NUMPY_TO_PYLIBCUDF_TYPES[np.dtype(dtype)]
)

# libcudf types don't support localization so convert to the base type
if isinstance(dtype, pd.DatetimeTZDtype):
dtype = np.dtype(f"<M8[{dtype.unit}]")
else:
dtype = np.dtype(dtype)
return pylibcudf.DataType(SUPPORTED_NUMPY_TO_PYLIBCUDF_TYPES[dtype])

cdef bool is_decimal_type_id(libcudf_types.type_id tid) except *:
return tid in (
Expand Down

0 comments on commit ce381e1

Please sign in to comment.