Certified Associate Developer for Apache Spark Exam QuestionsBrowse all questions from this exam

Certified Associate Developer for Apache Spark Exam - Question 75


The code block shown below should return a new DataFrame with the mean of column sqft from DataFrame storesDF in column sqftMean. Choose the response that correctly fills in the numbered blanks within the code block to complete this task.

Code block:

storesDF.__1__(__2__(__3__).alias("sqftMean"))

Show Answer
Correct Answer: A

To create a new DataFrame with the mean of a column in another DataFrame, you typically use the 'agg' method to perform an aggregation. Inside 'agg', you use 'mean' to compute the average and 'col' to reference the specific column, in this case 'sqft'. Thus, the correct code block is 'storesDF.agg(mean(col('sqft')).alias('sqftMean'))'.

Discussion

1 comment
Sign in to comment
cookiemonster42Option: A
Jul 31, 2023

A is the right one