nerdexam
Databricks

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…

Manipulate and clean data using Spark DataFrames

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
    1. na
  • B
    1. na
  • C
    1. na
  • D
    1. na
  • E
    1. drop

How the community answered

(34 responses)
  • B
    3% (1)
  • C
    3% (1)
  • D
    94% (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

#PySpark DataFrames#Missing Data Handling#Data Cleaning#DataFrameNaFunctions

Community Discussion

No community discussion yet for this question.

Full DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK Practice