nerdexam
Databricks

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…

Data Transformation and Manipulation

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

How the community answered

(48 responses)
  • A
    2% (1)
  • B
    2% (1)
  • C
    8% (4)
  • D
    73% (35)
  • E
    15% (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

#Spark DataFrames#Missing Data#Data Cleaning#PySpark

Community Discussion

No community discussion yet for this question.

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