1from collections import Counter
2data_list = [1,1,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4]
3least_common = Counter(data_list).most_common()[-1]
4print(least_common)
5# The number 1 appears 2 times
6(1, 2)
1import collections
2c = collections.Counter(a=1, b=2, c=3)
3n = 2
4
5print c.most_common()[:-n-1:-1]Output[('a', 1), ('b', 2)]
6