Other packages Flashcards

1
Q

find the most common n items in a list

A
from collections import Counter
data = Counter(arr)
#data.most_common()   # Returns all unique items and their counts
data.most_common(n)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

find mode using python

A

max(set(arr), key = arr.count)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly