LeetQuiz Logo
Privacy Policy•contact@leetquiz.com
© 2025 LeetQuiz All rights reserved.
Databricks Certified Associate Developer for Apache Spark

Databricks Certified Associate Developer for Apache Spark

Get started today

Ultimate access to all questions.


The code block shown below should return a new DataFrame where single quotes in column storeSlogan have been replaced with double quotes. Choose the response that correctly fills in the numbered blanks within the code block to complete this task.

A sample of DataFrame storesDF is below:

storeId storeSlogan
0 consequat vitae …
1 'aliquam at pelle…
2 'non ac leo phare…
3 l'eget purus vel sed"
4 'vitae phasellus …

Code block:

storesDF.__1__(__2__, __3__(__4__, __5__, __6__))

Exam-Like




Explanation:

To replace single quotes with double quotes in the 'storeSlogan' column, the correct approach involves using the 'withColumn' method to create a new column or update the existing one. The 'regexp_replace' function is used for replacing strings, where the first argument is the column to operate on, the second is the pattern to match (single quotes), and the third is the replacement string (double quotes). Option C correctly uses 'withColumn' with 'regexp_replace', specifying the column as 'col("storeSlogan")', and correctly orders the replacement from single to double quotes. Options A and E incorrectly use 'regexp_extract', which is for extracting substrings, not replacing them. Option B uses incorrect syntax for column references. Option D reverses the order of the replacement strings, which would replace double quotes with single quotes, the opposite of the intended operation.

Powered ByGPT-5