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

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

    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
azure_bimonsterOption: E

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.