About 13,300,000 results
Open links in new tab
  1. How to sort Counter by value? - python - Stack Overflow

    Other than doing list comprehensions of reversed list comprehension, is there a pythonic way to sort Counter by value? If so, it is faster than this: >>> from collections import Counter &...

  2. python - Using a dictionary to count the items in a list - Stack …

    If you are only interested in counting instances of a single element in a list, see How do I count the occurrences of a list item?.

  3. python - How do I count the occurrences of a list item? - Stack …

    Apr 8, 2010 · Given a single item, how do I count occurrences of it in a list, in Python? A related but different problem is counting occurrences of each different element in a collection, getting …

  4. How do I measure elapsed time in Python? - Stack Overflow

    The python cProfile and pstats modules offer great support for measuring time elapsed in certain functions without having to add any code around the existing functions.

  5. How to add or increment single item of the Python Counter class

    A set uses .update to add multiple items, and .add to add a single one. Why doesn't collections.Counter work the same way? To increment a single Counter item using …

  6. Behaviour of increment and decrement operators in Python

    Sep 28, 2009 · Also, be aware that, in Python, += and friends are not operators that can be used in expressions. Rather, in Python they are defined as part of an "augmented assignment …

  7. sorting a counter in python by keys - Stack Overflow

    sorting a counter in python by keys Asked 12 years, 5 months ago Modified 1 year, 10 months ago Viewed 69k times

  8. Find the item with maximum occurrences in a list [duplicate]

    Although the time complexity of using max() is worse than using Counter.most_common(1) as PM 2Ring comments, the approach benefits from a rapid C implementation and I find this …

  9. Python: count repeated elements in the list - Stack Overflow

    Apr 23, 2014 · Closed 3 years ago. I am new to Python. I am trying to find a simple way of getting a count of the number of elements repeated in a list e.g.

  10. python - How to increment a shared counter from multiple …

    Here is a solution to your problem based on a different approach from that proposed in the other answers. It uses message passing with multiprocessing.Queue objects (instead of shared …