Certified Associate Developer for Apache Spark Exam QuestionsBrowse all questions from this exam

Certified Associate Developer for Apache Spark Exam - Question 154


Which of the following code blocks fails to return the number of rows in DataFrame storesDF for each distinct combination of values in column division and column storeCategory?

Show Answer
Correct Answer: B

The code block that fails to return the number of rows in DataFrame storesDF for each distinct combination of values in column division and column storeCategory is the one that attempts to group by column division and then tries to group by storeCategory on an already grouped DataFrame. This results in an error since 'GroupedData' object doesn't have a groupBy method. Therefore, the correct option is storesDF.groupBy('division').groupBy('storeCategory').count().

Discussion

2 comments
Sign in to comment
YiJiaSuOption: D
Feb 18, 2024

D is correct !

Ahlo
Feb 27, 2024

it is possible to run in pyspark - storesDF.groupBy("division", "storeCategory").count() Correct answer is B

SaiPavan10Option: B
Apr 3, 2024

B is the right choice. I tested with my dataframe option B threw this error AttributeError: 'GroupedData' object has no attribute 'groupBy'