DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #88
Which of the following sets of DataFrame methods will both return a new DataFrame only containing rows that meet a specified logical condition?
The correct answer is C. filter(), where(). filter() and where() are functionally identical aliases in DataFrame APIs like PySpark - both return a new DataFrame containing only the rows that satisfy a given boolean condition, which makes C correct. Why the distractors are wrong: select() (B, D) operates on columns, not…
Question
Which of the following sets of DataFrame methods will both return a new DataFrame only containing rows that meet a specified logical condition?
Options
- Adrop(), where()
- Bfilter(), select()
- Cfilter(), where()
- Dselect(), where()
- Efilter(), drop()
How the community answered
(35 responses)- A3% (1)
- B3% (1)
- C89% (31)
- D6% (2)
Explanation
filter() and where() are functionally identical aliases in DataFrame APIs like PySpark - both return a new DataFrame containing only the rows that satisfy a given boolean condition, which makes C correct.
Why the distractors are wrong:
select()(B, D) operates on columns, not rows - it returns a DataFrame with only the specified columns, ignoring row conditions entirely.drop()(A, E) also operates on columns - it removes named columns from the DataFrame rather than filtering rows.
Memory tip: Think of filter/where as SQL's WHERE clause (rows), and select/drop as column-level operations (like SELECT col or DROP COLUMN). The word "where" itself is the giveaway - it belongs in the row-filtering category alongside filter().
Topics
Community Discussion
No community discussion yet for this question.