Exam Certified Associate Developer for Apache Spark All QuestionsBrowse all questions from this exam
Question 38

Which of the following code blocks returns all the rows from DataFrame storesDF?

    Correct Answer: B

    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.

Discussion
4be8126Option: B

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.

mahmoud_salah30Option: B

b correct