Quiz: Sorting Columns, Filtering, and Indexing Operations.

Quiz yourself on sorting columns, filtering, and indexing operations.

1

Look at the given DataFrame df:

     Name    col2  col3    
r1   Fred    1     5    
r2   Carl    2     6    
r3   Alice   3     7    
r4   BoB     4     8

We want to display the DataFrame in alphabetical order with respect to the column Name as shown below:

     Name    col2    col3    
r3   Alice    3    7    
r4   BoB      4    8
r2   Carl     2    6    
r1   Fred     1    5

Which command will achieve this?

A)

df.sort_values(by = 'Name', ascending = False)

B)

df.sort_values(by = 'Name', ascending = True)

C)

df.sort_values(by = 'Name', descending = False)

D)

df.sort_values(by = 'Name', descending = True)

Question 1 of 70 attempted

Get hands-on with 1200+ tech skills courses.