QuestionQ241

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

A DataFrame df contains the columns name, age, and salary. The developer needs to sort the DataFrame by age in ascending order and by salary in descending order.

Which code snippet satisfies the developer's requirement?

Explanation

PySpark DataFrame.orderBy accepts multiple sort columns and an ascending list whose Boolean values correspond to those columns in order. True sorts age ascending, and False sorts salary descending.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!