Arrange the following steps to perform a multi-column sort in pandas:
A. import pandas as pd
B. use .sort_values() with multiple columns and ascending parameter
C. load data into DataFrame
D. display the sorted DataFrame
Arrange the following steps to perform a multi-column sort in pandas:
A. import pandas as pd
B. use .sort_values() with multiple columns and ascending parameter
C. load data into DataFrame
D. display the sorted DataFrame
Solution
✅ Correct Option: 1
A. Import pandas as pd, so that its functions are available.
C. Load the data into a DataFrame, for example with .
B. Use .sort_values() with a list of columns and the ascending parameter, for example .
D. Display the sorted DataFrame.
Option 4: the DataFrame cannot be created before pandas is imported.
Options 2 and 3: sorting cannot happen before the data is loaded.
Related questions:
2025: 22 May Shift 1
2025: 27 May Shift 2
2025: 21 May Shift 1
2026: 18 May Shift 2