DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #109
The code block shown below should return a new DataFrame where rows in DataFrame storesDF with missing values in every column have been dropped. Choose the response that correctly fills in the…
The correct answer is D. 1. na. To drop rows where ALL columns contain missing (null/NaN) values, you use the DataFrame.na accessor followed by drop(how='all'). The na accessor returns a DataFrameNaFunctions object that exposes null-handling methods including drop(), fill(), and replace(). The how parameter…
Question
The code block shown below should return a new DataFrame where rows in DataFrame storesDF with missing values in every column 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
(34 responses)- B3% (1)
- C3% (1)
- D94% (32)
Explanation
To drop rows where ALL columns contain missing (null/NaN) values, you use the DataFrame.na accessor followed by drop(how='all'). The na accessor returns a DataFrameNaFunctions object that exposes null-handling methods including drop(), fill(), and replace(). The how parameter accepts 'any' (drop a row if any column is null - the default) or 'all' (drop a row only if every column is null). Answer D correctly specifies: 1=na, 2=drop, 3=how, 4='all'. The full call is: storesDF.na.drop(how='all').
Topics
Community Discussion
No community discussion yet for this question.