Skip to main contentSkip to solution

Pandas provides ____ function to sort the data values of a DataFrame.

Solution

✅ Correct Option: 4

Pandas provides the method DataFrame.sort_values() to sort a DataFrame by the values in one or more columns. The column is given with the by parameter, for example df.sort_values(by='Marks', ascending=False).


Option 1 and Option 3: pandas has no sort object or module with a values() function, so these do not exist.

Option 2: the name needs an underscore. sortvalues() is not a valid pandas method.

To sort by row or column labels instead of values, use DataFrame.sort_index().

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question