Pandas provides ____ function to sort the data values of a DataFrame.
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().
Related questions:
2025: 15 May Shift 2
2025: 27 May Shift 2
2026: 29 May Shift 1