Skip to content

Instantly share code, notes, and snippets.

@selwin
Created September 2, 2013 06:06
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 selwin/6409650 to your computer and use it in GitHub Desktop.
Save selwin/6409650 to your computer and use it in GitHub Desktop.
Find most common email domains
from collections import defaultdict
from collections import Counter
emails = User.objects.values_list('email', flat=True)
domains = defaultdict(int)
for email in emails:
try:
domain = email.split('@')[1]
domains[domain] += 1
except:
pass
counter = Counter(domains)
counter.most_common(20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment