Horje
how to get the most common number in python Code Example
python find most occuring element
from collections import Counter

a = [1936, 2401, 2916, 4761, 9216, 9216, 9604, 9801] 

c = Counter(a)

print(c.most_common(1)) # the one most common element... 2 would mean the 2 most common
[(9216, 2)] # a set containing the element, and it's count in 'a'
how to get the most common number in python
>>> from statistics import mode
>>> mode((1, 2, 4, 4, 5, 4, 4, 2, 3, 8, 4, 4, 4))
4




Python

Related
pickle python Code Example pickle python Code Example
python if defined Code Example python if defined Code Example
access column pandas Code Example access column pandas Code Example
python iter on a dic key value Code Example python iter on a dic key value Code Example
python if not null Code Example python if not null Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7