DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK-3-0 practice question 7 of 25

The code block displayed below contains an error. The code block is intended to return all columns of DataFrame transactionsDf except for columns predError, productId, and value. Find the error. Excerpt of DataFrame transactionsDf: transactionsDf.select(~col("predError"), ~col("productId"), ~col("value"))

Full set: 180 questions
Answer options
A: The select operator should be replaced by the drop operator and the arguments to the drop operator should be column names predError, productId and value wrapped in the col operator so they should be expressed like drop(col(predError), col(productId), col(value)).
B: The select operator should be replaced with the deselect operator.
C: The column names in the select operator should not be strings and wrapped in the col operator, so they should be expressed like select(~col(predError), ~col(productId), ~col(value)).
D: The select operator should be replaced by the drop operator.
E: The select operator should be replaced by the drop operator and the arguments to the drop operator should be column names predError, productId and value as strings. (Correct) Correct answer
Correct Answer:
E. The select operator should be replaced by the drop operator and the arguments to the drop operator should be column names predError, productId and value as strings. (Correct)
Explanation

Correct code block: transactionsDf.drop("predError", "productId", "value") Static notebook | Dynamic notebook: See test 1,

Scroll to Top