Posts by zeh • 101 points
1 post
-
0
votes2
answers22
viewsA: how to create an udf using two columns and if expression
You need the Else in the if-else in the same line. It follows as it should be: selection = F.udf(lambda x: cumulative_sum._1 if 100*random.random()<= x else float(0.0), FloatType())…