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

Certified Associate Developer for Apache Spark Exam - Question 80


Which of the following code blocks applies the function assessPerformance() to each row of DataFrame storesDF?

Show Answer
Correct Answer: E

The correct code block to apply the function assessPerformance() to each row of a DataFrame storesDF is storesDF.collect.foreach(row => assessPerformance(row)). The collect() method retrieves all the rows of the DataFrame as an array, and foreach() applies the provided function to each element of this array.

Discussion

1 comment
Sign in to comment
azure_bimonsterOption: E
Feb 9, 2024

Short explanation below: - collect() retrieves all the rows of the DataFrame and returns them as an array. - foreach() applies the specified function to each element of the array. So, in this case, foreach(row => assessPerformance(row)) applies the function assessPerformance() to each row of the DataFrame storesDF.