daft.expressions.Expression.apply#

Expression.apply(func: Callable, return_type: Optional[type] = None) daft.expressions.Expression[source]#

Apply a function on a given expression

Example

>>> def f(x_val: str) -> int:
>>>     return int(x_val) if x_val.isnumeric() else 0
>>>
>>> col("x").apply(f, return_type=int)
Parameters
  • func (Callable) – Function to run per value of the expression

  • return_type (Optional[Type], optional) – Return type of the function that was ran. This defaults to None and Daft will infer the return_type from the function’s type annotations if available.

Returns

New expression after having run the function on the expression

Return type

Expression