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…
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
- DataFrame
- B
- DataFrame
- C
- storesDF
- D
- storesDF
- E
- DataFrame
How the community answered
(18 responses)- A6% (1)
- B11% (2)
- C78% (14)
- E6% (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
Community Discussion
No community discussion yet for this question.