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

Method count_by_key

functional/pipeline.py:908–916  ·  view source on GitHub ↗

Reduces a sequence of (Key, Value) by counting each key >>> seq([('a', 1), ('b', 2), ('b', 3), ('b', 4), ('c', 3), ('c', 0)]).count_by_key() [('a', 1), ('b', 3), ('c', 2)] :return: Sequence of tuples where value is the count of each key

(self)

Source from the content-addressed store, hash-verified

906 return self._transform(transformations.reduce_by_key_t(func))
907
908 def count_by_key(self):
909 """
910 Reduces a sequence of (Key, Value) by counting each key
911
912 >>> seq([('a', 1), ('b', 2), ('b', 3), ('b', 4), ('c', 3), ('c', 0)]).count_by_key()
913 [('a', 1), ('b', 3), ('c', 2)]
914 :return: Sequence of tuples where value is the count of each key
915 """
916 return self._transform(transformations.count_by_key_t())
917
918 def count_by_value(self):
919 """

Callers 1

test_count_by_keyMethod · 0.80

Calls 1

_transformMethod · 0.95

Tested by 1

test_count_by_keyMethod · 0.64