Databricks Certified Associate Developer for Apache Spark — Question 147

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__)

Answer options

Correct answer: D

Explanation

The correct answer is D because it uses the 'drop' method on 'na' values with 'how' set to 'any', which ensures that any row with at least one missing value is removed. Option A incorrectly uses 'subset' instead of 'how', while options B and C use 'all', which would only drop rows if all values are missing, which is not the requirement. Option E incorrectly places 'drop' before 'na', which is not the correct syntax.