1. Home
  2. Data Science
  3. Pandas
  4. What does df.sort_values(by='x', ascending=False) do?

Added 30 Nov -0001

What does df.sort_values(by='x', ascending=False) do?

  1. Ranks x without reordering rows
  2. Sorts rows by x, largest first Correct answer
  3. Sorts columns by x, largest first
  4. Drops rows where x is negative

Correct answer

B. Sorts rows by x, largest first

14 views

MCQSEXAM

Explanation

sort_values reorders the rows according to the named column, here from largest to smallest.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Pandas MCQs

Practise all Pandas MCQs

Similar MCQs