DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #154
The code block shown below should return a new DataFrame where rows in DataFrame storesDF containing at least one missing value have been dropped. Choose the response that correctly fills in the…
The correct answer is D. 1. na. PySpark DataFrames expose null-handling utilities via the .na property, which returns a DataFrameNaFunctions object. The drop() method on that object removes rows containing null values. The how parameter controls the threshold: how='any' drops a row if at least one column is…
Question
The code block shown below should return a new DataFrame where rows in DataFrame storesDF containing at least one missing value have been dropped. Choose the response that correctly fills in the numbered blanks within the code block to complete this task. Code block:
StoresDF.1.2(3 = 4)
Options
- A
- na
- B
- na
- C
- na
- D
- na
- E
- drop
How the community answered
(48 responses)- A2% (1)
- B2% (1)
- C8% (4)
- D73% (35)
- E15% (7)
Explanation
PySpark DataFrames expose null-handling utilities via the .na property, which returns a DataFrameNaFunctions object. The drop() method on that object removes rows containing null values. The how parameter controls the threshold: how='any' drops a row if at least one column is null (which matches the requirement), while how='all' would only drop rows where every column is null. The correct full expression is: storesDF.na.drop(how='any'). Option E lists 'drop' as blank 1, which skips the required .na intermediary and would fail.
Topics
Community Discussion
No community discussion yet for this question.