daft.Expression.cast

daft.Expression.cast#

Expression.cast(dtype: DataType) Expression[source]#

Casts an expression to the given datatype if possible

Example

>>> # [1.0, 2.5, None]: float32 -> [1, 2, None]: int64
>>> col("float").cast(DataType.int64())
>>>
>>> # [Path("/tmp1"), Path("/tmp2"), Path("/tmp3")]: Python -> ["/tmp1", "/tmp1", "/tmp1"]: utf8
>>> col("path_obj_col").cast(DataType.string())
Returns:

Expression with the specified new datatype

Return type:

Expression