美文网首页
from collections import Counter

from collections import Counter

作者: 康河水 | 来源:发表于2020-03-27 23:36 被阅读0次
from collections import Counter

skuPurchaseCount = [3, 8, 3, 10, 3, 3, 1, 3, 7, 6, 1, 2, 7, 0, 7, 9, 1, 5, 1, 0]

Counter(skuPurchaseCount).most_common()

# 仅仅一行代码,便输出统计计数结果,并且是一个按照次数统计出来的由大到小排序好的tuples列表
# [(3, 5),(1, 4),(7, 3),(0, 2),(8, 1),(10, 1),(6, 1),(2, 1),(9, 1),(5, 1)]

相关文章

网友评论

      本文标题:from collections import Counter

      本文链接:https://www.haomeiwen.com/subject/kfeduhtx.html