Python code for aggregation
Nicer python to drive aggregation