Pass a list to collections.Counter to count each distinct value. For example, Counter(["open", "closed", "open"])["open"] returns 2. Use most_common() for the most frequent values. If the list contains repeated events for the same ticket, decide first whether you want to count events or tickets.
Count labels and inspect the result
from collections import Counter
labels = ["review", "approved", "review", "returned"]
counts = Counter(labels)
assert counts["review"] == 2
assert counts["unknown"] == 0
assert counts.total() == 4
print(counts.most_common(2))
counts.total() is available in Python 3.10 and later. A missing key read by subscription returns zero. That convenience does not prove the category existed in the source. If your report needs to distinguish a known category with zero recorded events from an unexpected category, hold an approved category list separately and validate labels against it.
Counter("review") counts characters. Counter(["review"]) counts one complete label. Counter({"review": 3}) receives a mapping of labels to existing counts. Keep those input shapes separate when extracting columns, parsing a delimited export or combining pre-aggregated records.
Count events, people, or records
Suppose a ticket table includes three rows for the same ticket because its status changed twice. Counting those rows describes status events. If a supervisor asks how many tickets are currently in each status, first resolve one current row per ticket using its update order. If orders have more than one category, the total of category counts can exceed the number of unique orders. Include the distinction in your report.
Normalize a label only when the data rule supports it. A stray trailing space after approved may be safe to trim. If two teams use the same name for different states, joining both labels creates a misleading total. Report unexpected labels and keep the raw record usable for review. Unknown and missing labels often deserve their own visible counts.
Make ties and empty results predictable
most_common() gives the highest counts first and uses the order in which equal-count values first appeared to break ties. That can change if input order changes. For a published table, choose a deterministic tie rule. For text labels, sorted(counts.items(), key=lambda item: (-item[1], item[0])) uses count descending and label ascending. An alphabetical tie-breaker is a display choice, not evidence that one tied category is more important.
An empty iterable produces an empty counter. Before reporting shares, check whether the total is zero. An empty batch and a batch whose rows all failed validation both leave a blank chart. The report should tell the reader which happened.
Combine batches with the right operation
update() adds counts from input items or from a mapping of counts. It is useful when file batches describe different, nonoverlapping records. Keep track of which batches were included. Applying the same file twice will add its counts twice. For large files, process one record at a time or in chunks, holding only counts and other small summaries. Memory still depends on how many distinct labels there are.
Counters can represent zero or negative counts in arithmetic workflows. subtract() can leave negative values, while arithmetic such as adding two counters with + keeps positive results. If you are comparing a current count against a baseline, choose a signed difference deliberately. A category missing from the output might represent a decrease that the chosen operator discarded.
Validate with a small reference example
Construct a miniature input with one repeated value, one missing label and two equal-count categories. Determine expected outputs without running code first. Assert both the high-level total and the count for a known key. For a real report, spot-check a handful of raw records and reconcile recorded, unknown and excluded rows. That check catches the cases where Python counts perfectly while the input selection answers the wrong question.