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

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.