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

The code block displayed below contains an error. The code block should count the number of rows that have a predError of either 3 or 6. Find the error. Code block: transactionsDf.filter(col('predError').in([3, 6])).count()

Full set: 180 questions
Answer options
A: The number of rows cannot be determined with the count() operator.
B: Instead of filter, the select method should be used.
C: The method used on column predError is incorrect. Correct answer
D: Instead of a list, the values need to be passed as single arguments to the in operator.
E: Numbers 3 and 6 need to be passed as string variables.
Correct Answer:
C. The method used on column predError is incorrect.
Explanation

Correct code block: transactionsDf.filter(col('predError').isin([3, 6])).count() The isin method is the correct one to use here – the in method does not exist for the Column object. More info: pyspark.sql.Column.isin — PySpark 3.1.2 documentation

Scroll to Top