Commit 72a95cc7 authored by Raymond Hettinger's avatar Raymond Hettinger

Sync-up 3.1 docs with 2.7 for collections.Counter().

parent 0f31e6db
...@@ -236,13 +236,12 @@ Common patterns for working with :class:`Counter` objects:: ...@@ -236,13 +236,12 @@ Common patterns for working with :class:`Counter` objects::
c.most_common()[:-n:-1] # n least common elements c.most_common()[:-n:-1] # n least common elements
c += Counter() # remove zero and negative counts c += Counter() # remove zero and negative counts
Several multiset mathematical operations are provided for combining Several mathematical operations are provided for combining :class:`Counter`
:class:`Counter` objects. Multisets are like regular sets but are allowed to objects to produce multisets (counters that have counts greater than zero).
contain repeated elements (with counts of one or more). Addition and Addition and subtraction combine counters by adding or subtracting the counts
subtraction combine counters by adding or subtracting the counts of of corresponding elements. Intersection and union return the minimum and
corresponding elements. Intersection and union return the minimum and maximum maximum of corresponding counts. Each operation can accept inputs with signed
of corresponding counts. Each operation can accept inputs with signed counts, counts, but the output will exclude results with counts of zero or less.
but the output excludes results with counts less than one.
>>> c = Counter(a=3, b=1) >>> c = Counter(a=3, b=1)
>>> d = Counter(a=1, b=2) >>> d = Counter(a=1, b=2)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment