nerdexam
Databricks

DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #74

The code block shown below contains an error. The code block is intended to return a collection of summary statistics for column sqft in Data Frame storesDF. Identify the error. Code block…

The correct answer is E. The describe()operation does not accept a Column object as an argument - the column name. The describe() method in Spark accepts column names as plain String arguments, not Column objects created with col(). The correct call is storesDF.describe("sqft"), not storesDF.describe(col("sqft")). Additionally, the code has a typo: describes should be describe. These two…

Performing Data Analysis with Spark DataFrames

Question

The code block shown below contains an error. The code block is intended to return a collection of summary statistics for column sqft in Data Frame storesDF. Identify the error. Code block:

storesDF.describes(col("sgft"))

Options

  • AThe column sqft should be subsetted from DataFrame storesDF prior to computing summary
  • BThe describe() operation does not accept a Column object as an argument outside of a sequence
  • CThe describe()operation doesn't compute summary statistics for a single column - the summary()
  • DThe describe()operation doesn't compute summary statistics for numeric columns - the
  • EThe describe()operation does not accept a Column object as an argument - the column name

How the community answered

(52 responses)
  • A
    4% (2)
  • B
    2% (1)
  • D
    2% (1)
  • E
    92% (48)

Explanation

The describe() method in Spark accepts column names as plain String arguments, not Column objects created with col(). The correct call is storesDF.describe("sqft"), not storesDF.describe(col("sqft")). Additionally, the code has a typo: describes should be describe. These two issues - the method name typo and passing a Column object instead of a String - are both errors, but the primary API contract violation is using col() where a string is required.

Topics

#Spark DataFrames#DataFrame API#Descriptive Statistics#API Usage

Community Discussion

No community discussion yet for this question.

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