Created
October 2, 2018 04:36
-
-
Save neuromusic/0f3c70fff0f95cdbd1bbee7b433877c0 to your computer and use it in GitHub Desktop.
pure python mode
This file contains 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
def mode(vals): | |
unique = set(vals) | |
unique, counts = zip(*((v,vals.count(v)) for v in unique)) | |
return unique[counts.index(max(counts))] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment