Skip to content

Commit

Permalink
Work around #10181
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 committed Apr 13, 2024
1 parent acf3482 commit 2674b67
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion python-package/xgboost/data.py
Expand Up @@ -909,9 +909,16 @@ def _transform_cudf_df(
enable_categorical: bool,
) -> Tuple[ctypes.c_void_p, list, Optional[FeatureNames], Optional[FeatureTypes]]:
try:
from cudf.api.types import is_categorical_dtype
from cudf.api.types import is_categorical_dtype, is_bool_dtype
except ImportError:
from cudf.utils.dtypes import is_categorical_dtype
from pandas.api.types import is_bool_dtype

# Work around https://github.com/dmlc/xgboost/issues/10181
if _is_cudf_ser(data) and is_bool_dtype(data.dtype):
data = data.astype(np.uint8)
else:
data = data.astype({col: np.uint8 for col in data.select_dtypes(include="bool")})

if _is_cudf_ser(data):
dtypes = [data.dtype]
Expand Down

0 comments on commit 2674b67

Please sign in to comment.