Having in Pandas

Having condition can be applied in pandas after group by is performed. Pandas provide a filter function that can be applied on grouped data frame

Example : Select students where the class has more than 1 student
import pandas
data = pandas.DataFrame({'Student Name' : ['Anil', 'Musk','Bill'], 
                        'Class' : [1,2,2], 
                        'Age' : [6, 7, 8 ]})
output = data.groupby(data["Class"])
output.filter(lambda g: len(g) > 1)


Output
indexAgeClassStudent Name
172Musk
282Bill