Python Numpy Aggregate Functions Postgresql Database