Certified Associate Developer for Apache Spark Exam QuestionsBrowse all questions from this exam

Certified Associate Developer for Apache Spark Exam - Question 68


Which of the following code blocks returns a new DataFrame from DataFrame storesDF where column modality is the constant string "PHYSICAL"? Assume DataFrame storesDF is the only defined language variable.

Show Answer
Correct Answer: C

To return a new DataFrame where the column 'modality' is set to the constant string 'PHYSICAL', you need to use the 'withColumn' method along with the 'lit' function to create a column with a constant value. The correct code block is 'storesDF.withColumn("modality", lit("PHYSICAL"))'. This correctly assigns the constant string 'PHYSICAL' to the 'modality' column.

Discussion

1 comment
Sign in to comment
Sowwy1Option: C
Apr 5, 2024

should be C