Databricks Certified Associate Developer for Apache Spark — Question 27

Which of the following code blocks returns a new DataFrame where column division from DataFrame storesDF has been replaced and renamed to column state and column managerName from DataFrame storesDF has been replaced and renamed to column managerFullName?

Answer options

Correct answer: E

Explanation

The correct answer is E because it specifically uses the method withColumnRenamed to change the names of the columns as required. Options A, B, C, and D do not correctly rename the columns; A incorrectly tries to rename two columns simultaneously in a single method, B and C do not rename but rather create new columns, and D reverses the renaming process.