
Explanation:
The question asks which code block applies the function assessPerformance() to each row of DataFrame storesDF. The correct approach involves collecting the DataFrame to the driver (as an Array[Row]) and iterating over each row.
assessPerformance(row) is evaluated immediately, but row is undefined in this context. Also, collect should be called with parentheses (collect()).apply() is used to access elements by index, not to apply a function to all rows.apply() is for indexing, not iteration.map requires a function, but assessPerformance(row) is invalid syntax here (no lambda).collect.foreach (equivalent to collect().foreach) iterates over each row, and the lambda row => assessPerformance(row) properly applies the function.Only Option E uses valid syntax and logic to apply the function to each row.
Ultimate access to all questions.
No comments yet.
Which of the following code blocks correctly applies the assessPerformance() function to each row of the DataFrame storesDF?
A
storesDF.collect.foreach(assessPerformance(row))
B
storesDF.collect().apply(assessPerformance)
C
storesDF.collect.apply(row => assessPerformance(row))
D
storesDF.collect.map(assessPerformance(row))
E
storesDF.collect.foreach(row => assessPerformance(row))