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

The code block displayed below contains an error. The code block should return all rows of DataFrame transactionsDf, but including only columns storeId and predError. Find the error. Code block: spark.collect(transactionsDf.select("storeId", "predError"))

Full set: 180 questions
Answer options
A: Instead of select, DataFrame transactionsDf needs to be filtered using the filter operator.
B: Columns storeId and predError need to be represented as a Python list, so they need to be wrapped in brackets ([]).
C: The take method should be used instead of the collect method.
D: Instead of collect, collectAsRows needs to be called.
E: The collect method is not a method of the SparkSession object. Correct answer
Correct Answer:
E. The collect method is not a method of the SparkSession object.
Explanation

Correct code block: transactionsDf.select("storeId", "predError").collect() collect() is a method of the DataFrame object. More info: pyspark.sql.DataFrame.collect — PySpark 3.1.2 documentation Static notebook | Dynamic notebook: See test 2,

Scroll to Top