Postgresql Count Distinct Not Null Python