QuestionQ274

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

Which of the following code blocks returns a new DataFrame in which the division column from DataFrame storesDF has been replaced and renamed to state, and the managerName column from DataFrame storesDF has been replaced and renamed to managerFullName?

Explanation

PySpark DataFrame.withColumnRenamed(existing, new) returns a new DataFrame with an existing column renamed. Chaining it with division to state and managerName to managerFullName performs both required renames without retaining columns under their original names.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!