Certified Associate Developer for Apache Spark Exam QuestionsBrowse all questions from this exam

Certified Associate Developer for Apache Spark Exam - Question 151


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:

Show Answer
Correct Answer: BD

To remove the pattern ' End' from the end of the column 'storeReview' in the DataFrame 'storesDF', the correct code block should use the 'regexp_replace' function along with the 'col' function correctly. The correct implementation is 'storesDF.withColumn("storeReview", regexp_replace(col("storeReview"), " End$", ""))'. This method ensures that the 'regexp_replace' function operates on the column 'storeReview,' replacing the pattern ' End' that appears at the end of the string. Therefore, option B is the correct choice.

Discussion

4 comments
Sign in to comment
saryuOption: B
Feb 2, 2024

B also works right?

SaiPavan10Option: B
Apr 3, 2024

B is the right choice

azure_bimonsterOption: B
Feb 9, 2024

B is right one it seems, col should be used

jtu363Option: B
May 23, 2024

B & D work