Skip to content

featurebyte.ViewColumn.astype

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

Description

Converts the data type of a column. It is useful when you need to convert column 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

Convert a numerical series to a string series, and back to an int series.

>>> event_view = catalog.get_view("GROCERYINVOICE")
>>> event_view["Amount"] = event_view["Amount"].astype(str)
>>> event_view["Amount"] = event_view["Amount"].astype(int)