Postgresql Array Agg Group By Function In Pandas