QuestionQ84

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

The code block below contains an error. It is intended to return a new DataFrame that results from a position-wise union of DataFrame storesDF and DataFrame acquiredStoresDF. Identify the error.

storesDF.unionByName(acquiredStoresDF)  
Explanation

PySpark DataFrame.unionByName() aligns the two DataFrames’ columns by column name, not by their ordinal positions. A position-wise union uses DataFrame.union(), which resolves columns by position.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!