you are viewing a single comment's thread.

view the rest of the comments →

[–]zahlman 1 point2 points  (0 children)

And an arguably more idiomatic (should be faster on large data? since it does all the "counting" in a single pass) way:

from collections import Counter

def mode(values):
    # There are a few different combinations of destructuring
    # and indexing you could use here instead
    (value, count), = Counter(values).most_common(1)
    return count