Retrieve elements with max occurences with a DRAW(tie) in the max occurrence

Eg., I have the following list
[s, d, s, e, d, d, s]

I need to print the elements with highest occurrences.
example output:
d 2
s 2

enter image description here

So far, i have been able to get only one element with highest occurrence. Please help me deal with the tie or draw in the max occurrence.

>Solution :

You could do something like this:

counts = df[0].value_counts()
counts = counts[counts == counts.max()]

Output:

>>> counts
s    3
d    3
Name: 0, dtype: int64

>>> counts['s']
3

>>> counts['d']
3

Leave a Reply