Lines Matching defs:count

539     >>> c = Counter('abcdeabcdabcaba')  # count elements from a string
550 >>> c['a'] # count of letter 'a'
553 ... c[elem] += 1 # by adding 1 to each element's count
569 Note: If a count is set to zero or reduced to zero, it will remain
573 >>> c['b'] -= 2 # reduce the count of 'b' by two
574 >>> c.most_common() # 'b' is still in, but its count is zero
586 '''Create a new, empty Counter object. And if given, count elements
587 from an input iterable. Or, initialize the count from another mapping
600 'The count of elements not in the Counter is zero.'
625 '''Iterator over elements repeating each as many times as its count.
637 Note, if an element's count has been set to zero or is a negative
682 for elem, count in iterable.items():
683 self[elem] = count + self_get(elem, 0)
711 for elem, count in iterable.items():
712 self[elem] = self_get(elem, 0) - count
822 for elem, count in self.items():
823 newcount = count + other[elem]
826 for elem, count in other.items():
827 if elem not in self and count > 0:
828 result[elem] = count
832 ''' Subtract count, but keep only results with positive counts.
841 for elem, count in self.items():
842 newcount = count - other[elem]
845 for elem, count in other.items():
846 if elem not in self and count < 0:
847 result[elem] = 0 - count
860 for elem, count in self.items():
862 newcount = other_count if count < other_count else count
865 for elem, count in other.items():
866 if elem not in self and count > 0:
867 result[elem] = count
880 for elem, count in self.items():
882 newcount = count if count < other_count else other_count
890 for elem, count in self.items():
891 if count > 0:
892 result[elem] = count
901 for elem, count in self.items():
902 if count < 0:
903 result[elem] = 0 - count
907 '''Internal method to strip elements with a negative or zero count'''
908 nonpositive = [elem for elem, count in self.items() if not count > 0]
922 for elem, count in other.items():
923 self[elem] += count
935 for elem, count in other.items():
936 self[elem] -= count
949 count = self[elem]
950 if other_count > count:
963 for elem, count in self.items():
965 if other_count < count:
1306 def count(self, item):
1307 return self.data.count(item)
1429 def count(self, sub, start=0, end=_sys.maxsize):
1432 return self.data.count(sub, start, end)