`pandas.DataFrame` has a function called `group_by`, link [here](http://pandas.pydata.org/pandas-docs/version/0.13.1/generated/pandas.DataFrame.groupby.html). Have you check that it applies here?