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$", ""))
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
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.
max_manfred
1 month, 1 week agojtu363
6 months agoSaiPavan10
7 months, 3 weeks agoazure_bimonster
9 months, 2 weeks agosaryu
9 months, 3 weeks ago