def cudf_dtype_from_pydata_dtype(dtype): """ Given a numpy or pandas dtype, converts it into the equivalent cuDF Python dtype. """ if is_categorical_dtype(dtype): return cudf.core.dtypes.CategoricalDtype elif dtype in cudf._lib.types.np_to_cudf_types: return dtype.type return infer_dtype_from_object(dtype)
def cudf_dtype_from_pydata_dtype(dtype): """ Given a numpy or pandas dtype, converts it into the equivalent cuDF Python dtype. """ from pandas.core.dtypes.common import infer_dtype_from_object if is_categorical_dtype(dtype): return cudf.core.dtypes.CategoricalDtype elif np.issubdtype(dtype, np.datetime64): dtype = np.datetime64 return infer_dtype_from_object(dtype)
def cudf_dtype_from_pydata_dtype(dtype): """Given a numpy or pandas dtype, converts it into the equivalent cuDF Python dtype. """ if cudf.api.types.is_categorical_dtype(dtype): return cudf.core.dtypes.CategoricalDtype elif cudf.api.types.is_decimal32_dtype(dtype): return cudf.core.dtypes.Decimal32Dtype elif cudf.api.types.is_decimal64_dtype(dtype): return cudf.core.dtypes.Decimal64Dtype elif cudf.api.types.is_decimal128_dtype(dtype): return cudf.core.dtypes.Decimal128Dtype elif dtype in cudf._lib.types.SUPPORTED_NUMPY_TO_LIBCUDF_TYPES: return dtype.type return infer_dtype_from_object(dtype)
def cudf_dtype_from_pydata_dtype(dtype): """ Given a numpy or pandas dtype, converts it into the equivalent cuDF Python dtype. """ try: # pd 0.24.X from pandas.core.dtypes.common import \ infer_dtype_from_object except ImportError: # pd 0.23.X from pandas.core.dtypes.common import \ _get_dtype_from_object as infer_dtype_from_object if pd.api.types.is_categorical_dtype(dtype): pass elif np.issubdtype(dtype, np.datetime64): dtype = np.datetime64 return infer_dtype_from_object(dtype)