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

Certified Associate Developer for Apache Spark Exam - Question 38


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

Show Answer
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

2 comments
Sign in to comment
4be8126Option: B
Apr 26, 2023

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
Dec 31, 2023

b correct