
Answer-first summary for fast verification
Answer: storesDF.take(3), storesDF.head(3)
The correct methods to retrieve the first 3 rows of a DataFrame in Apache Spark are `take(3)` and `head(3)`. `take(3)` returns the first `n` rows as a list of `Row` objects, and `head(3)` returns the first `n` rows, similar to `take(3)`. Other options provided are invalid as they either do not exist (`top_n(3)`, `n(3)`) or are used incorrectly (`collect(3)`).
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.