DEA-C02 · Question #26
Which methods will trigger an action that will evaluate a DataFrame? (Choose two.)
The correct answer is B. DataFrame.collect() E. DataFrame.show(). In Apache Spark, transformations are lazy - they build a logical plan but don't execute until an action is called. DataFrame.collect() (B) triggers execution by pulling all data into the driver as a Python list, and DataFrame.show() (E) triggers execution by fetching and…
Question
Which methods will trigger an action that will evaluate a DataFrame? (Choose two.)
Options
- ADataFrame.random_split()
- BDataFrame.collect()
- CDataFrame.select()
- DDataFrame.col()
- EDataFrame.show()
How the community answered
(34 responses)- B91% (31)
- C3% (1)
- D6% (2)
Explanation
In Apache Spark, transformations are lazy - they build a logical plan but don't execute until an action is called. DataFrame.collect() (B) triggers execution by pulling all data into the driver as a Python list, and DataFrame.show() (E) triggers execution by fetching and printing rows to the console. Both force Spark to evaluate the full computation DAG.
The distractors are all transformations, not actions:
- A.
random_split()- splits a DataFrame into multiple DataFrames lazily; no computation runs. - C.
select()- narrows columns but returns a new DataFrame without evaluating anything. - D.
col()- is a column expression builder, not even a DataFrame method that returns a DataFrame.
Memory tip: If the method returns a DataFrame, it's almost certainly a transformation (lazy). If it returns data to you - a list (collect()), printed output (show()), a count (count()), etc. - it's an action that triggers evaluation. Ask yourself: "Am I getting data back, or just a new plan?"
Topics
Community Discussion
No community discussion yet for this question.