Which of the following code blocks returns all the rows from DataFrame storesDF?
Which of the following code blocks returns all the rows from DataFrame storesDF?
The collect() method collects all the rows of the DataFrame into a list and returns it. While other methods like head(), take(), count(), and show() either show a subset of rows or provide specific information, collect() is the one that returns all the rows from the DataFrame.
Answer: B Explanation: head() returns the first n rows of the DataFrame. By default, it returns the first 5 rows. collect() returns an array of Row objects that represent the entire DataFrame. count() returns the number of rows in the DataFrame. take(n) returns the first n rows of the DataFrame as an array of Row objects. show() prints the first 20 rows of the DataFrame in a tabular form. Only collect() returns all the rows from the DataFrame.
b correct