Python Numpy Aggregate Functions Postgresql Create Table Foreign