nerdexam
Databricks

DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #180

Which of the following code blocks returns a DataFrame where rows in DataFrame storesDF containing missing values in every column have been dropped?

The correct answer is D. storesDF.na.drop("all"). storesDF.na.drop('all') drops only the rows where every column contains a null (missing) value. The 'all' argument means a row is dropped only if all its values are null. Choice A (na.drop() with no arguments) uses the default 'any', which drops rows that have at least one null…

Data Preparation and Transformation

Question

Which of the following code blocks returns a DataFrame where rows in DataFrame storesDF containing missing values in every column have been dropped?

Options

  • AstoresDF.na.drop()
  • BstoresDF.dropna()
  • CstoresDF.na.drop("all", subset = "sqft")
  • DstoresDF.na.drop("all")
  • EstoresDF.nadrop("all")

How the community answered

(26 responses)
  • A
    4% (1)
  • B
    4% (1)
  • C
    4% (1)
  • D
    88% (23)

Explanation

storesDF.na.drop('all') drops only the rows where every column contains a null (missing) value. The 'all' argument means a row is dropped only if all its values are null. Choice A (na.drop() with no arguments) uses the default 'any', which drops rows that have at least one null in any column. Choice B (dropna()) is pandas syntax and is not valid for Spark DataFrames. Choice C applies 'all' but restricts the check to the sqft subset. Choice E uses nadrop() which is not a valid method.

Topics

#Spark DataFrames#Missing Values#na.drop#Data Cleaning

Community Discussion

No community discussion yet for this question.

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