from pyspark.sql.functions import when @time_decorator def no_udf(data): # Use when and otherwise to discount the amount based on conditions discounted_data = data.withColumn( "discountedTotalAmt", when(data.state == "CA", data.totalAmt * 0.90) # 10% off .otherwise(data.totalAmt * 0.85)) # 15% off # Show the results return discounted_data.select("customerID", "totalAmt", "state", "discountedTotalAmt").show() display(no_udf(df))