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

Method group_by_key

functional/pipeline.py:884–893  ·  view source on GitHub ↗

Group sequence of (Key, Value) elements by Key. >>> seq([('a', 1), ('b', 2), ('b', 3), ('b', 4), ('c', 3), ('c', 0)]).group_by_key() [('a', [1]), ('c', [3, 0]), ('b', [2, 3, 4])] :return: sequence grouped by key

(self)

Source from the content-addressed store, hash-verified

882 return self._transform(transformations.group_by_t(func))
883
884 def group_by_key(self):
885 """
886 Group sequence of (Key, Value) elements by Key.
887
888 >>> seq([('a', 1), ('b', 2), ('b', 3), ('b', 4), ('c', 3), ('c', 0)]).group_by_key()
889 [('a', [1]), ('c', [3, 0]), ('b', [2, 3, 4])]
890
891 :return: sequence grouped by key
892 """
893 return self._transform(transformations.group_by_key_t())
894
895 def reduce_by_key(self, func):
896 """

Callers 1

test_group_by_keyMethod · 0.80

Calls 1

_transformMethod · 0.95

Tested by 1

test_group_by_keyMethod · 0.64