Skip to content

Instantly share code, notes, and snippets.

@Linus-Albertus
Last active May 26, 2019 10:57
Show Gist options
  • Save Linus-Albertus/65b81c8c473559991fd9dbd27caeb5b8 to your computer and use it in GitHub Desktop.
Save Linus-Albertus/65b81c8c473559991fd9dbd27caeb5b8 to your computer and use it in GitHub Desktop.
[most frequent elements] Take a list of elements and return their frequency #python #collections #freqs
from collections import Counter
count = Counter(a_list_of_repeated_elements)
print(count.most_common(3)) # Show the 3 more frequent elements of a list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment