Databricks Certified Associate Developer for Apache Spark — Question 158
Which of the following operations can be used to rename and replace an existing column in a DataFrame?
Answer options
- A. DataFrame.renamedColumn()
- B. DataFrame.withColumnRenamed()
- C. DataFrame.wlthColumn()
- D. col()
- E. DataFrame.newColumn()
Correct answer: B
Explanation
The correct answer is B, as DataFrame.withColumnRenamed() is specifically designed to change the name of a column in a DataFrame. The other options either do not exist or do not serve the purpose of renaming a column.