daft.expressions.Expression.if_else
daft.expressions.Expression.if_else#
- Expression.if_else(if_true: daft.expressions.expressions.Expression, if_false: daft.expressions.expressions.Expression) daft.expressions.expressions.Expression [source]#
Conditionally choose values between two expressions using the current boolean expression as a condition
Example
>>> # x = [2, 2, 2] >>> # y = [1, 2, 3] >>> # a = ["a", "a", "a"] >>> # b = ["b", "b", "b"] >>> # if_else_result = ["a", "b", "b"] >>> (col("x") > col("y")).if_else(col("a"), col("b"))
- Parameters
if_true (Expression) – Values to choose if condition is true
if_false (Expression) – Values to choose if condition is false
- Returns
New expression where values are chosen from
if_true
andif_false
.- Return type