Postgresql Window Function Count Python String Replace Character