nerdexam
Databricks

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…

Performing Data Aggregations with Spark DataFrames and SQL

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)
  • B
    90% (18)
  • D
    5% (1)
  • E
    5% (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

#Spark DataFrames#Aggregate Functions#Statistical Operations#PySpark

Community Discussion

No community discussion yet for this question.

Full DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK Practice