Skip to content

Commit

Permalink
Use try except
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke committed Feb 1, 2024
1 parent 4babccc commit 4ff4a2a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion python/cudf/cudf/utils/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ def cudf_dtype_from_pydata_dtype(dtype):
"""Given a numpy or pandas dtype, converts it into the equivalent cuDF
Python dtype.
"""
dtype = cudf.dtype(dtype)
try:
dtype = cudf.dtype(dtype)
except TypeError:
return infer_dtype_from_object(dtype)

if isinstance(dtype, cudf.CategoricalDtype):
return cudf.core.dtypes.CategoricalDtype
elif cudf.api.types.is_decimal32_dtype(dtype):
Expand Down

0 comments on commit 4ff4a2a

Please sign in to comment.