cast
Cast(target_type, *, features=None)
Bases: Transform
Cast features to a different datatype.
This transform allows to change the datatype of features in a DataFrame.
To cast all features to the same datatype, provide a single type as the
target_type
argument e.g.
transform = Cast(pl.Float64)
By specifying the features
keyword argument, only the selected features
will be cast e.g.
transform = Cast(pl.Float64, features=["feature_a"])
Lastly, to cast features to different datatypes, provide a dictionary with feature names as keys and target types as values e.g.
transform = Cast(
{
"feature_a": pl.Boolean,
"feature_b": pl.Float64,
},
)
Initializes the Cast transform.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_type
|
PolarsDataType | dict[str, PolarsDataType]
|
Type to which the features will be cast.
If a single type is provided, all features or those provided in
the |
required |
features
|
Iterable[str] | None
|
The features to cast. If |
None
|
Source code in src/flowcean/polars/transforms/cast.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
|