DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #157
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 D. The describe() operation does not accept a Column object as an argument - the column name. describe() accepts column names as plain string arguments, not Column objects created by col(). The correct call is storesDF.describe('sqft'). Passing col('sqft') - a Column object - is the error the question targets. Additionally, the code has a typo ('describes' instead of…
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 describe() operation doesn't compute summary statistics for a single column - the summary()
- BThe column sqft should be subsetted from DataFrame storesDF prior to computing summary
- CThe describe() operation does not accept a Column object as an argument outside of a list - the list
- DThe describe() operation does not accept a Column object as an argument - the column name
- EThe describe() operation doesn't compute summary statistics for numeric columns - the sumwary()
How the community answered
(34 responses)- A6% (2)
- B3% (1)
- C3% (1)
- D88% (30)
Explanation
describe() accepts column names as plain string arguments, not Column objects created by col(). The correct call is storesDF.describe('sqft'). Passing col('sqft') - a Column object - is the error the question targets. Additionally, the code has a typo ('describes' instead of 'describe'), but the identified error in answer D about the Column object argument type is the primary issue being tested. describe() does work on single numeric columns and is distinct from summary(), which computes a different (wider) set of statistics.
Topics
Community Discussion
No community discussion yet for this question.