Applies function to column expressions, column-wise. Output column type deduced from type-annotations of a function. Example: >>> import pathway as pw >>> def concat(left: str, right: str) -> str: ... return left+right >>> t1 = pw.debug.table_from_markdown(''' ... age
(
fun: Callable,
*args: expr.ColumnExpression | Value,
**kwargs: expr.ColumnExpression | Value,
)
| 94 | @check_arg_types |
| 95 | @trace_user_frame |
| 96 | def apply( |
| 97 | fun: Callable, |
| 98 | *args: expr.ColumnExpression | Value, |
| 99 | **kwargs: expr.ColumnExpression | Value, |
| 100 | ) -> expr.ColumnExpression: |
| 101 | """Applies function to column expressions, column-wise. |
| 102 | Output column type deduced from type-annotations of a function. |
| 103 | |
| 104 | Example: |
| 105 | |
| 106 | >>> import pathway as pw |
| 107 | >>> def concat(left: str, right: str) -> str: |
| 108 | ... return left+right |
| 109 | >>> t1 = pw.debug.table_from_markdown(''' |
| 110 | ... age owner pet |
| 111 | ... 10 Alice dog |
| 112 | ... 9 Bob dog |
| 113 | ... 8 Alice cat |
| 114 | ... 7 Bob dog''') |
| 115 | >>> t2 = t1.select(col = pw.apply(concat, t1.owner, t1.pet)) |
| 116 | >>> pw.debug.compute_and_print(t2, include_id=False) |
| 117 | col |
| 118 | Alicecat |
| 119 | Alicedog |
| 120 | Bobdog |
| 121 | Bobdog |
| 122 | """ |
| 123 | if kwargs: |
| 124 | warn( |
| 125 | "Passing keyword arguments to the function in pw.apply is deprecated. Use positional arguments instead.", |
| 126 | DeprecationWarning, |
| 127 | stacklevel=5, |
| 128 | ) |
| 129 | return udf(fun)(*args, **kwargs) |
| 130 | |
| 131 | |
| 132 | def apply_with_type( |