
Answer-first summary for fast verification
Answer: The describe()operation does not accept a Column object as an argument — the column name string “sqft” should be specified instead.
The code block contains a typo in the column name ('sgft' instead of 'sqft') and incorrectly passes a Column object to the `describe()` method. The `describe()` method in Spark expects column names as strings, not Column objects. Therefore, the correct approach is to pass the column name as a string, like `storesDF.describe("sqft")`. The options provided focus on the method's requirements rather than the typo, making option E the correct choice as it accurately identifies the issue with passing a Column object to `describe()`.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
Identify the error in the following code block intended to return summary statistics for the column sqft in DataFrame storesDF:
Code block:
storesDF.describe(col("sgft"))
storesDF.describe(col("sgft"))
A
The column sqft should be subsetted from DataFrame storesDF prior to computing summary statistics on it alone.
B
The describe() operation does not accept a Column object as an argument outside of a sequence — the sequence Seq(col(“sqft”)) should be specified instead.
C
The describe()operation doesn’t compute summary statistics for a single column — the summary() operation should be used instead.
D
The describe()operation doesn't compute summary statistics for numeric columns — the summary() operation should be used instead.
E
The describe()operation does not accept a Column object as an argument — the column name string “sqft” should be specified instead.