QuestionQ226

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

The code block below must return a new DataFrame from DataFrame storesDF in which column modality is the constant string "PHYSICAL". Assume storesDF is the only defined language variable. Choose the response that correctly fills the numbered blanks in the code block to complete this task.

storesDF. _1_(_2_,_3_(_4_))  
Explanation

DataFrame.withColumn returns a new DataFrame after adding or replacing a named column and requires a Column expression as its second argument. lit("PHYSICAL") produces a Column containing the literal string value, so withColumn("modality", lit("PHYSICAL")) creates or replaces modality with that constant for every row.

Learn more

Community Discussion

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