What is itertools.groupby?
Comprehensions and functional tools
Audio flashcard · 0:14Nortren·
What is itertools.groupby?
0:14
Groupby takes an iterable and produces consecutive groups of equal elements, returning each group as a key and an iterator. It groups only adjacent equal elements, so the input usually needs to be sorted first. It is useful for run-length encoding and similar patterns.
---
docs.python.org