Name Test Course Marks Ajay 1 Commerce 50 Alok 1 Information practices 40 Arun 1 Physics 60
Consider the above given dataframe as 'df'.
With reference to the pandas function sort_values(), which parameter is used to specify the column name?
| Name | Test | Course | Marks |
|---|---|---|---|
| Ajay | 1 | Commerce | 50 |
| Alok | 1 | Information practices | 40 |
| Arun | 1 | Physics | 60 |
Consider the above given dataframe as 'df'.
With reference to the pandas function sort_values(), which parameter is used to specify the column name?
Solution
✅ Correct Option: 2
The by parameter of sort_values() takes the column name (or a list of column names) to sort on, so df.sort_values(by=['Marks']) sorts the rows by the Marks column in ascending order.
Options 1, 3 and 4: using, with and in are not parameters of sort_values(), so they raise a TypeError. Note that with and in are also reserved Python keywords, so they cannot be used as argument names at all.
Use ascending=False along with by to sort in descending order.
Related questions:
2026: 29 May Shift 2
2026: 18 May Shift 2
2025: 16 May Shift 1
2025: 16 May Shift 1