nerdexam
Databricks

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

The code block shown below should return a new DataFrame that is the result of a position-wise union between DataFrame storesDF and DataFrame acquiredStoresDF. Choose the response that correctly…

The correct answer is C. 1. storesDF. The correct PySpark method for a position-wise union (stacking rows) is DataFrame.union(otherDataFrame). Position-wise means rows are combined by column position, not by column name. The correct complete call is storesDF.union(acquiredStoresDF). Options A, B, and E use…

Working with Spark DataFrames

Question

The code block shown below should return a new DataFrame that is the result of a position-wise union between DataFrame storesDF and DataFrame acquiredStoresDF. 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. DataFrame
  • B
    1. DataFrame
  • C
    1. storesDF
  • D
    1. storesDF
  • E
    1. DataFrame

How the community answered

(18 responses)
  • A
    6% (1)
  • B
    11% (2)
  • C
    78% (14)
  • E
    6% (1)

Explanation

The correct PySpark method for a position-wise union (stacking rows) is DataFrame.union(otherDataFrame). Position-wise means rows are combined by column position, not by column name. The correct complete call is storesDF.union(acquiredStoresDF). Options A, B, and E use DataFrame as a literal object reference, which is invalid - you must call the method on an actual DataFrame instance. Option D fills in storesDF.union(acquiredStoresDF), which is identical to C and is also correct, but based on the answer key, C is the designated answer. The method unionByName() exists for name-based unions, but the question specifies position-wise.

Topics

#Spark DataFrame API#DataFrame Transformations#Union Operation#Data Manipulation

Community Discussion

No community discussion yet for this question.

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