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

Certified Associate Developer for Apache Spark Exam - Question 67


The code block shown below should return a new DataFrame from DataFrame storesDF where column storeId is of the type string. Choose the response that correctly fills in the numbered blanks within the code block to complete this task.

Code block:

storesDF.__1__("storeId", __2__("storeId").__3__(__4__)

Show Answer
Correct Answer: A

To create a new DataFrame where the storeId column is cast to a string type, we use the withColumn method of DataFrame to create or replace a column. The col function selects the column, and the cast method is used to change its type. Finally, StringType() specifies the target data type.

Discussion

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

should be A