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 183 discussion

Which of the following code blocks returns a DataFrame where column managerName from DataFrame storesDF is split at the space character into column managerFirstName and column managerLastName?

A sample of DataFrame storesDF is displayed below:

  • A. (storesDF.withColumn("managerFirstName", split(col("managerName"), " ")[0])
    .withColumn("managerLastName", split(col("managerName"), " ")[1]))
  • B. (storesDF.withColumn("managerFirstName", col("managerName"). split(" ")[1])
    .withColumn("managerLastName", col("managerName").split(" ")[2]))
  • C. (storesDF.withColumn("managerFirstName", split(col("managerName"), " ")[1])
    .withColumn("managerLastName", split(col("managerName"), " ")[2]))
  • D. (storesDF.withColumn("managerFirstName", col("managerName").split(" ")[0])
    .withColumn("managerLastName", col("managerName").split(" ")[1]))
  • E. (storesDF.withColumn("managerFirstName", split("managerName"), " ")[0])
    .withColumn("managerLastName", split("managerName"), " ")[1]))
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
thinkbang
1 week, 3 days ago
Selected Answer: A
basic documentation
upvoted 1 times
...
max_manfred
1 month, 1 week ago
Right answer is A as the array returned by the split function is 0-based not 1-based. You can try yourself with the following code: df = spark.createDataFrame([('John Doe',)], ['Person',]) df2 = df \ .withColumn('first_name', split(col('Person'), ' ')[0]) \ .withColumn('last_name', split(col('Person'), ' ')[1]) df2.show()
upvoted 2 times
...
sofiess
1 month, 2 weeks ago
(storesDF.withColumn("managerFirstName", split(col("managerName"), " ")[0]) .withColumn("managerLastName", split(col("managerName"), " ")[1]))
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 ...