Postgresql Window Function Count Python Array Append