DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #155
Which of the following operations calculates the simple average of a group of values, like a column?
The correct answer is B. mean(). In PySpark, mean() (imported from pyspark.sql.functions) computes the arithmetic average of a numeric column and is the standard aggregate function for this purpose. It is equivalent to avg(). The other options are invalid: simpleAvg(), average(), and approxMean() do not exist…
Question
Which of the following operations calculates the simple average of a group of values, like a column?
Options
- AsimpleAvg()
- Bmean()
- Cagg()
- Daverage()
- EapproxMean()
How the community answered
(20 responses)- B90% (18)
- D5% (1)
- E5% (1)
Explanation
In PySpark, mean() (imported from pyspark.sql.functions) computes the arithmetic average of a numeric column and is the standard aggregate function for this purpose. It is equivalent to avg(). The other options are invalid: simpleAvg(), average(), and approxMean() do not exist in the PySpark API. agg() is a DataFrame method used to apply one or more aggregate functions, but it is not itself an averaging function - you would call mean() or avg() inside agg().
Topics
Community Discussion
No community discussion yet for this question.