Databricks Certified Associate Developer for Apache Spark — Question 90
The code block shown below should return a new DataFrame where column division from DataFrame storesDF has been renamed to column state and column managerName from DataFrame storesDF has been renamed to column managerFullName. Choose the response that correctly fills in the numbered blanks within the code block to complete this task.
Code block:
storesDF. __1__(__2__, __2__).__4__(__5__, __6__)
Answer options
- A. 1. withColumnRenamed 2."state" 3."division" 4.withColumnRenamed 5."managerFullName" 6."managerName"
- B. 1.withColumnRenamed 2.division 3.col("state") 4. withColumnRenamed 5."managerName" 6.col("managerFullName")
- C. 1. WithColumnRenamed 2. "division" 3."state" 4. withColumnRenamed 5. "managerName" 6."managerFullName"
- D. 1. withColumn 2. "division" 3. "state" 4.withcolumn 5."managerName" 6."managerFullName
- E. 1. withColumn 2. "division" 3. "state" 4. withColumn 5."managerName" 6."managerFullName"
Correct answer: C
Explanation
Option C is the correct answer because it correctly uses the method withColumnRenamed to rename the specified columns in the DataFrame. Options A and B have incorrect identifiers or do not correspond properly to the required renaming tasks, while options D and E incorrectly use the method withColumn instead of withColumnRenamed.