added groupby to extract.py