Skip to content

Instantly share code, notes, and snippets.

@jakul
Created March 6, 2014 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakul/9395379 to your computer and use it in GitHub Desktop.
Save jakul/9395379 to your computer and use it in GitHub Desktop.
users and practices with multiple plhone numbers / addresses
pns = PhoneNumber.objects.filter(content_type=38L).order_by('object_id').values_list('object_id', flat=True)
pns2 = [(key, len(list(group))) for key, group in groupby(pns)]
[(key, freq) for key, freq in pns2 if freq> 2]
3
31
38
pns = Address.objects.filter(content_type=38).order_by('object_id').values_list('object_id', flat=True)
pns2 = [(key, len(list(group))) for key, group in groupby(pns)]
[(key, freq) for key, freq in pns2 if freq> 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment