QuestionQ58

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

Which of the following code blocks returns a new DataFrame whose storeDescription column has the pattern "Description: " removed from the beginning of that column in the storesDF DataFrame?

A sample of the storesDF DataFrame is shown below:

Question Image

Choose two
Explanation

PySpark regexp_replace replaces regex matches using the signature (string, pattern, replacement). The regular expression ^Description: matches that text only at the beginning of each value, and replacing it with an empty string removes the prefix. Its first argument may be either the column name or a Column object, so both forms are valid.

Learn more

Community Discussion

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