python what does .mode mean code example
Example 1: statistics mode python when no.s are same
import statistics
statistics.mode(x)
Example 2: my_mode() python
>>> from collections import Counter
>>> def my_mode(sample):
... c = Counter(sample)
... return [k for k, v in c.items() if v == c.most_common(1)[0][1]]
...
>>> my_mode(["male", "male", "female", "male"])
['male']
>>> my_mode(["few", "few", "many", "some", "many"])
['few', 'many']
>>> my_mode([4, 1, 2, 2, 3, 5])
[2]
>>> my_mode([4, 1, 2, 2, 3, 5, 4])
[4, 2]