Created
September 2, 2013 06:06
-
-
Save selwin/6409650 to your computer and use it in GitHub Desktop.
Find most common email domains
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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