Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Certified Associate Developer for Apache Spark All Questions

View all questions & answers for the Certified Associate Developer for Apache Spark exam

Exam Certified Associate Developer for Apache Spark topic 1 question 28 discussion

Which of the following code blocks returns a new DataFrame where column division from DataFrame storesDF has been replaced and renamed to column state and column managerName from DataFrame storesDF has been replaced and renamed to column 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"))
Show Suggested Answer Hide Answer
Suggested Answer: E 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
4be8126
Highly Voted 1 year, 7 months ago
Selected Answer: E
Option E is the correct answer. The withColumnRenamed function renames an existing column, whereas withColumn creates a new column. To replace the "division" column with a new column "state" and rename the "managerName" column to "managerFullName", we need to use withColumnRenamed. So option E is correct, where we first rename "division" to "state" and then rename "managerName" to "managerFullName".
upvoted 7 times
...
azure_bimonster
Most Recent 9 months, 3 weeks ago
Selected Answer: E
E is the right answer for this question
upvoted 2 times
...
evertonllins
1 year, 3 months ago
Selected Answer: B
If we take in consideration this part of the text .-> "has been REPLACED and renamed to..." it means that the columnis not only renames but replaved with the contents of the other clumn. In this case the righr answer is B. Do you guys thin this insterpretation is correct? Thanks for the feedback.
upvoted 3 times
...
zozoshanky
1 year, 4 months ago
D is right
upvoted 1 times
...
NickWerbung
1 year, 4 months ago
DataFrame.withColumnRenamed(existing, new)
upvoted 2 times
...
Mohitsain
1 year, 5 months ago
Selected Answer: D
this is the right answer.
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...