mirror of https://github.com/python/cpython
Clarify Counter() docs.
This commit is contained in:
parent
e3bc0eff25
commit
a665853bab
|
@ -251,14 +251,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 counters with the restriction
|
objects to produce multisets (counters that have counts greater than zero).
|
||||||
that all counts are at least one. They are like regular sets but are
|
Addition and subtraction combine counters by adding or subtracting the counts
|
||||||
allowed to contain repeated elements. Addition and subtraction combine
|
of corresponding elements. Intersection and union return the minimum and
|
||||||
counters by adding or subtracting the counts of corresponding elements.
|
maximum of corresponding counts. Each operation can accept inputs with signed
|
||||||
Intersection and union return the minimum and maximum of corresponding
|
counts, but the output will exclude results with counts of zero or less.
|
||||||
counts. Each operation can accept inputs with signed counts,
|
|
||||||
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)
|
||||||
|
|
Loading…
Reference in New Issue