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

Which of the following code blocks returns a new DataFrame with column storeReview where the pattern "End" has been removed from the end of column storeReview in DataFrame storesDF?

A sample DataFrame storesDF is below:

  • A. storesDF.withColumn("storeReview", col("storeReview").regexp_replace(" End$", ""))
  • B. storesDF.withColumn("storeReview", regexp_replace(col("storeReview"), " End$", ""))
  • C. storesDF.withColumn("storeReview”, regexp_replace(col("storeReview"), " End$"))
  • D. storesDF.withColumn("storeReview", regexp_replace("storeReview", " End$", ""))
  • E. storesDF.withColumn("storeReview", regexp_extract(col("storeReview"), " End$", ""))
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
max_manfred
1 month, 1 week ago
the official documentation says pyspark.sql.functions.regexp_replace(str, pattern, replacement) Replace all substrings of the specified string value that match regexp with rep. so I think D is the only correct option
upvoted 1 times
...
jtu363
6 months ago
Selected Answer: B
B & D work
upvoted 2 times
...
SaiPavan10
7 months, 3 weeks ago
Selected Answer: B
B is the right choice
upvoted 2 times
...
azure_bimonster
9 months, 2 weeks ago
Selected Answer: B
B is right one it seems, col should be used
upvoted 1 times
...
saryu
9 months, 3 weeks ago
B also works right?
upvoted 3 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 ...