Python Numpy Aggregate Functions Postgresql Create Sequence Labels