How do I sort a data frame using multiple columns such that each column is sorted in different order? For example, the primary sort key is column 'A' in ascending order and secondary sort key is column 'B' in descending order.
            Asked
            
        
        
            Active
            
        
            Viewed 233 times
        
    1 Answers
0
            
            
        The method df.sort_values has a parameter ascending wich can be a boolean or a list of booleans.
df.sort_values(['A', 'B'], ascending=[True, False], inplace=True)
 
    
    
        RichieV
        
- 5,103
- 2
- 11
- 24
