Skip to content

featurebyte.Feature.astype

astype(
new_type: Union[Type[int], Type[float], Type[str], Literal["int", "float", "str"]]
) -> FrozenSeriesT

Description

Modifies the data type of a feature. It is useful when you need to convert feature values between numerical and string formats, or the other way around.

Parameters

  • new_type: Union[Type[int], Type[float], Type[str], Literal["int", "float", "str"]]
    Desired type after conversion. Type can be provided directly, or as a string.

Returns

  • FrozenSeriesT
    A new Series with converted variable type.

Examples

>>> feature = catalog.get_feature("InvoiceCount_60days")
>>> string_invoice_count_feature = feature.astype(str)
>>> float_invoice_count_feature = feature.astype(float)