QuestionQ267

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

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

A sample DataFrame storesDF is shown below:

Question Image

Choose two
Explanation

PySpark regexp_replace replaces every match of a regular expression with a replacement value, and its first parameter may be either a Column or a column-name string. The anchored pattern End$ matches only the trailing End, while "" removes that match. Therefore, both forms that target storeReview—using col("storeReview") or the name "storeReview"—produce the required column.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!