QuestionQ195

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

Which of the following code blocks returns a new DataFrame in which the productCategories column contains only one word per row, producing many more rows than the storesDF DataFrame?

A sample of storesDF is shown below:

Question Image

Choose two
Explanation

PySpark explode returns one row for every element of an array or map. It accepts either a Column object, such as col("productCategories"), or the column name string directly. Both forms therefore expand each productCategories array into separate rows. split creates an array rather than expanding rows, and explode is a function rather than a Column method.

Learn more

Community Discussion

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