ENH: new average_groups.py