
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:
- The column
division
from DataFrame storesDF
is replaced and renamed to state
- The column
managerName
from DataFrame storesDF
is replaced and renamed to managerFullName
?
Which of the following code blocks returns a new DataFrame where:
- The column
division
from DataFramestoresDF
is replaced and renamed tostate
- The column
managerName
from DataFramestoresDF
is replaced and renamed tomanagerFullName
?
Exam-Like
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.