QuestionQ234

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

Which of the following code blocks returns a DataFrame in which the storeCategory column from DataFrame storesDF is split on the underscore character into the storeValueCategory and storeSizeCategory columns?

A sample of DataFrame storesDF is shown below:

Question Image

Choose two
Explanation

PySpark functions.split splits a string column into an array and accepts either a Column or the column name as its first argument. Array indexing is zero-based, so index 0 extracts VALUE and index 1 extracts MEDIUM from VALUE_MEDIUM; both forms using col("storeCategory") and the string "storeCategory" produce the required columns.

Learn more

Community Discussion

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