Postgresql Nested Aggregate Functions In Pandas