Databricks Certified Associate Developer for Apache Spark — Question 55
Which of the following code blocks returns the first 3 rows of DataFrame storesDF?
Answer options
- A. storesDF.top_n(3)
- B. storesDF.n(3)
- C. storesDF.take(3)
- D. storesDF.head(3)
- E. storesDF.collect(3)
Correct answer: C
Explanation
The correct answer is C, as the 'take' method retrieves the specified number of rows from the DataFrame. Options A and B do not exist in standard DataFrame operations, while D would return the first n rows as well, but is not as direct as the take method for this purpose. Option E collects data but is used for different purposes and does not limit to the first three rows.