Sort by in Pandas

Pandas provides sort_values method which can be used to sort the data frame based on particular column name

Example Sort data set by student name
import pandas
data = pandas.DataFrame({'StudentName' : ['Anil', 'Musk','Bill'], 
                        'Class' : [1,2,2], 
                        'Age' : [6, 7, 8 ]})
data.sort_values(by="StudentName")

Output
indexAgeClassStudentName
061Anil
282Bill
172Musk


Example Sort data set by student name in descending order
import pandas
data = pandas.DataFrame({'StudentName' : ['Anil', 'Musk','Bill'], 
                        'Class' : [1,2,2], 
                        'Age' : [6, 7, 8 ]})
data.sort_values(by="StudentName", ascending= False)

Output
indexAgeClassStudentName
172Musk
282Bill
061Anil