I have pandas DataFrame read from csv.
 import pandas as pd
 df = pd.read_csv("record.csv")
 df # data contain in csv 
 provinces  month  total number 
 BC         1      20
 Ontrio     1      10
 Ontrio     2      3
 BC         2      15
 Yukon      2      33
 Nunavut    3      17
 BC         3      6
 Yukon      3      3
What i want to get is the top 2 provinces of each month with the highest total number:
 provinces  month  total number 
 BC         1      20
 Ontrio     1      10
 BC         2      15
 Yukon      2      33
 Nunavut    3      17
 BC         3      6
I can done by using pandas query but how can i design a function to achieve the result?
 
    