
Explanation:
The correct answer is B. DataFrame.withColumnRenamed() is the method used to rename an existing column in a DataFrame. The other options are incorrect: A (renamedColumn) does not exist, C (wlthColumn) is a typo and should be withColumn(), which can replace a column's data but not rename it directly. D (col()) refers to a column object, and E (newColumn()) is not a valid method.
Ultimate access to all questions.
Which of the following operations can be used to rename and replace an existing column in a PySpark DataFrame?
A
DataFrame.renamedColumn()
B
DataFrame.withColumnRenamed()
C
DataFrame.wlthColumn()
D
col()
E
DataFrame.newColumn()
No comments yet.