QuestionQ171

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

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

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

PySpark uses DataFrame.agg to produce aggregate results. mean(col("sqft")) creates the mean aggregate expression for the sqft column, and alias("sqftMean") assigns its output column name.

Community Discussion

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