python counter least common
from collections import Counter
data_list = [1,1,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4]
least_common = Counter(data_list).most_common()[-1]
print(least_common)
# The number 1 appears 2 times
(1, 2)
python counter least common
from collections import Counter
data_list = [1,1,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4]
least_common = Counter(data_list).most_common()[-1]
print(least_common)
# The number 1 appears 2 times
(1, 2)
python counter least common
import collections
c = collections.Counter(a=1, b=2, c=3)
n = 2
print c.most_common()[:-n-1:-1]Output[('a', 1), ('b', 2)]
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us