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)
| 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 | """ |