
Explanation:
The question requires renaming columns 'division' to 'state' and 'managerName' to 'managerFullName', which implies the original columns should be replaced. Option E uses withColumnRenamed correctly to rename both columns. Other options either use incorrect syntax (A, C), create new columns without removing the originals (B), or reverse the renaming logic (D).
Ultimate access to all questions.
No comments yet.
Which of the following code blocks returns a new DataFrame where column division from DataFrame storesDF has been renamed to state and column managerName from DataFrame storesDF has been renamed to managerFullName?
A
(storesDF.withColumnRenamed(["division", "state"], ["managerName", "managerFullName"])
B
(storesDF.withColumn("state", col("division")) .withColumn("managerFullName", col("managerName")))
C
(storesDF.withColumn("state", "division") .withColumn("managerFullName", "managerName"))
D
(storesDF.withColumnRenamed("state", "division") .withColumnRenamed("managerFullName", "managerName"))
E
(storesDF.withColumnRenamed("division", "state") .withColumnRenamed("managerName", "managerFullName"))