2 ms·
Not to pick nits, but this is off by one. If you need the n most common elements, you should use c.most_common()[:-n-1:-1] because the element at c.most_
by natnat 15y ago
Not to pick nits, but this is off by one. If you need the n most common elements, you should use
c.most_common()[:-n-1:-1]
because the element at
c.most_common()[-n]
is actually the n-1th most common element.