QuestionQ64

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

Which of the following code blocks defines a Python UDF, assessPerformanceUDF(), using the integer-returning Python function assessPerformance(), and applies it to the customerSatisfaction Column in the storesDF DataFrame?

Explanation

udf creates a Python UDF from the Python function and accepts a return type as a DataType object. IntegerType() supplies the required integer type instance, and calling the resulting UDF with col("customerSatisfaction") produces a Column that withColumn can store as result.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!