MCPcopy Create free account
hub / github.com/EntilZha/PyFunctional / count_by_value

Method count_by_value

functional/pipeline.py:918–926  ·  view source on GitHub ↗

Reduces a sequence of items by counting each unique item >>> seq(['a', 'a', 'a', 'b', 'b', 'c', 'd']).count_by_value() [('a', 3), ('b', 2), ('c', 1), ('d', 1)] :return: Sequence of tuples where value is the count of each key

(self)

Source from the content-addressed store, hash-verified

916 return self._transform(transformations.count_by_key_t())
917
918 def count_by_value(self):
919 """
920 Reduces a sequence of items by counting each unique item
921
922 >>> seq(['a', 'a', 'a', 'b', 'b', 'c', 'd']).count_by_value()
923 [('a', 3), ('b', 2), ('c', 1), ('d', 1)]
924 :return: Sequence of tuples where value is the count of each key
925 """
926 return self._transform(transformations.count_by_value_t())
927
928 def reduce(self, func, *initial):
929 """

Callers 1

test_count_by_valueMethod · 0.80

Calls 1

_transformMethod · 0.95

Tested by 1

test_count_by_valueMethod · 0.64