Databricks Certified Associate Developer for Apache Spark

Databricks Certified Associate Developer for Apache Spark

Get started today

Ultimate access to all questions.


Which of the following code blocks returns a new DataFrame where:

  1. The column division from DataFrame storesDF is replaced and renamed to state
  2. The column managerName from DataFrame storesDF is replaced and renamed to managerFullName?





Explanation:

The question requires renaming columns 'division' to 'state' and 'managerName' to 'managerFullName' in the DataFrame. The correct method is withColumnRenamed, which takes the existing column name and the new name. Option A chains two withColumnRenamed calls to achieve both renames. Options B and C use withColumn, which creates new columns instead of renaming existing ones. Option D uses invalid syntax for withColumnRenamed, which does not accept sequences. Option E incorrectly reverses the renaming order.