nerdexam
Databricks

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

The code block shown below should return a DataFrame containing all columns from DataFrame storesDF except for column sqft and column customerSatisfaction. Choose the response that correctly fills…

The correct answer is C. 1. storesDF. Option C correctly places storesDF in position 1 because the dot-notation chain must begin with the DataFrame object - you call methods on the DataFrame, not the other way around. This gives the pattern storesDF.drop("sqft", "customerSatisfaction"), which is the standard…

Spark SQL and DataFrame Operations

Question

The code block shown below should return a DataFrame containing all columns from DataFrame storesDF except for column sqft and column customerSatisfaction. Choose the response that correctly fills in the numbered blanks within the code block to complete this task. Code block:

1.2(3)

Options

  • A
    1. drop
  • B
    1. storesDF
  • C
    1. storesDF
  • D
    1. storesDF
  • E
    1. drop

How the community answered

(30 responses)
  • A
    3% (1)
  • C
    83% (25)
  • D
    3% (1)
  • E
    10% (3)

Explanation

Option C correctly places storesDF in position 1 because the dot-notation chain must begin with the DataFrame object - you call methods on the DataFrame, not the other way around. This gives the pattern storesDF.drop("sqft", "customerSatisfaction"), which is the standard PySpark syntax for removing named columns while returning all others.

Options A and E are wrong because they place drop in position 1, making it the calling object - drop is a method, not a DataFrame, so drop.something(...) is syntactically meaningless. Options B and D also start with storesDF but differ in positions 2 and/or 3 - likely using an incorrect method name (e.g., remove, delete) or wrong argument format, neither of which exists on a PySpark DataFrame.

Memory tip: Think of it as a sentence - "the DataFrame drops the columns" - so the DataFrame (storesDF) always comes first, .drop() is the verb, and the column names are the objects being acted on.

Topics

#DataFrame API#Column Operations#Data Transformation#drop() Method

Community Discussion

No community discussion yet for this question.

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