Databricks Certified Associate Developer for Apache Spark — Question 110
Which of the following code blocks extracts the value for column sqft from the first row of DataFrame storesDF?
Answer options
- A. storesDF.first()[col("sqft")]
- B. storesDF[0]["sqft"]
- C. storesDF.collect(l)[0]["sqft"]
- D. storesDF.first.sqft
- E. storesDF.first().sqft
Correct answer: E
Explanation
Option E is correct because it properly calls the first method on the DataFrame and then accesses the sqft property. Options A and C use incorrect syntax for accessing DataFrame values, while B accesses a row using an index which is not a valid approach for a DataFrame. Option D lacks the parentheses needed to call the first method correctly.