From 081f4f5597d8b9a50615ba66bbdcda7ea936b363 Mon Sep 17 00:00:00 2001 From: Bo Bayles Date: Tue, 17 Apr 2018 21:26:14 -0500 Subject: [PATCH] Note about order in groupy_transform --- more_itertools/more.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/more_itertools/more.py b/more_itertools/more.py index 5d738c4a..f533f3e2 100644 --- a/more_itertools/more.py +++ b/more_itertools/more.py @@ -1345,6 +1345,10 @@ def groupby_transform(iterable, keyfunc=None, valuefunc=None): >>> [(k, ''.join(g)) for k, g in grouper] [(0, 'ab'), (1, 'cde'), (2, 'fgh'), (3, 'i')] + Note that the order of items in the iterable is significant. + Only adjacent items are grouped together, so if you don't want any duplicate + groups, you should sort the iterable by the key function. + """ valuefunc = (lambda x: x) if valuefunc is None else valuefunc return ((k, map(valuefunc, g)) for k, g in groupby(iterable, keyfunc))