We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 651416e commit b2458caCopy full SHA for b2458ca
utils.py
@@ -59,6 +59,11 @@ def is_in(elt, seq):
59
"""Similar to (elt in seq), but compares with 'is', not '=='."""
60
return any(x is elt for x in seq)
61
62
+def mode(data):
63
+ """Return the most common data item. If there are ties, return any one of them."""
64
+ [(item, count)] = Counter(data).most_common(1)
65
+ return item
66
+
67
# ______________________________________________________________________________
68
# argmin and argmax
69
0 commit comments