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

Which of the following code blocks fails to return a DataFrame reverse sorted alphabetically based on column division?

    Correct Answer: C

    The code block storesDF.orderBy(col("division").asc()) returns a DataFrame sorted in ascending order based on column division, not reverse sorted. Ascending order is the opposite of the required reverse alphabetical sorting.

Discussion
singh100Option: C

C is the answer. Only C will make the data in ascending order. Tested the code.

zozoshankyOption: E

E is right

lakhan0309Option: E

Option E is right answer

dbdantasOption: C

C is the correct answer

azurearchOption: C

C is the right answer because it returns the dataframe in ascending order.

mahmoud_salah30Option: B

b i tesetd ut

vishnuasOption: C

C. It is the only option "not returning" the dataframe in descending(reverse) order. All other formats are returning the descending order. In Oprtion E, if we import the desc function,. it will not throw error and will return the dataframe in descending order.

outwalkerOption: E

E. storesDF.sort(desc("division")) Option E correctly uses the desc function to specify the descending order for sorting. Thank you for providing additional information and clarification.

singh100Option: C

Option A and D is giving errors. ~ cannot be used in ascending. Right way is to use ascending=False. Most relevant option is C which is sorting the data in ascending order , Option A, D have some typos it should be = instead of ~.

ItsABOption: C

It's C: storesDF.orderBy(col("division").asc()) => storesDF.orderBy(col("division").desc())