gloria.cast_series_to_kind#
- gloria.cast_series_to_kind(series, kind)[source]#
Cast a
pandas.Series
to a canonical NumPy dtype chosen by its one-letter dtype kind code.This utility is useful for preparing data before calling
Gloria.fit()
, as each model supports different data types.- Parameters:
series (pd.Series) – The data to cast.
kind ({"u", "i", "f", "b"}) –
One-letter code defined by numpy.dtype.kind. The mapping used here is:
"u"
: unsigned integer →uint64
"i"
: signed integer →int64
"f"
: floating point →float64
"b"
: boolean →bool
- Returns:
The input series, cast to the corresponding dtype.
- Return type:
- Raises:
ValueError – If
kind
is not one of the supported codes or the cast fails (e.g. due to incompatible values).
Examples
>>> cast_series_to_kind(pd.Series([1, 2, 3]), "f").dtype dtype('float64')