Databricks Certified Associate Developer for Apache Spark — Question 32
Which of the following code blocks returns all the rows from DataFrame storesDF?
Answer options
- A. storesDF.head()
- B. storesDF.collect()
- C. storesDF.count()
- D. storesDF.take()
- E. storesDF.show()
Correct answer: B
Explanation
The correct answer is B because the collect() method retrieves all rows from a DataFrame as a list. The other options do not return all rows: head() returns the first few rows, count() gives the number of rows, take() retrieves a specified number of rows, and show() displays the rows but does not return them.