Exam Certified Associate Developer for Apache Spark All QuestionsBrowse all questions from this 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.

    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
Sowwy1Option: C

should be C