DatabricksDatabricks
DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #3
DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK Question #3: Real Exam Question with Answer & Explanation
The correct answer is B: storesDF.withColumn("storeId, col("storeId").cast(StringType())). See the full explanation below for the reasoning.
Working with Spark DataFrames and Transformations
Question
Which of the following code blocks returns a new DataFrame from DataFrame storesDF where column storeId is of the type string?
Options
- AstoresDF.withColumn("storeId, cast(col("storeId"), StringType()))
- BstoresDF.withColumn("storeId, col("storeId").cast(StringType()))
- CstoresDF.withColumn("storeId, cast(storeId).as(StringType)
- DstoresDF.withColumn("storeId, col(storeId).cast(StringType)
- EstoresDF.withColumn("storeId, cast("storeId").as(StringType()))
Topics
#DataFrame Transformations#Type Casting#PySpark API#withColumn
Community Discussion
No community discussion yet for this question.