Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e2a30cd

Browse files
miss-islingtonrhettinger
authored andcommitted
[3.6] bpo-27385: Clarify docstring for groupby() (GH-3738) (#3744)
(cherry picked from commit 49392c6)
1 parent 73c915a commit e2a30cd

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

Doc/library/itertools.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Iterator Arguments Results
5353
:func:`compress` data, selectors (d[0] if s[0]), (d[1] if s[1]), ... ``compress('ABCDEF', [1,0,1,0,1,1]) --> A C E F``
5454
:func:`dropwhile` pred, seq seq[n], seq[n+1], starting when pred fails ``dropwhile(lambda x: x<5, [1,4,6,4,1]) --> 6 4 1``
5555
:func:`filterfalse` pred, seq elements of seq where pred(elem) is false ``filterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8``
56-
:func:`groupby` iterable[, keyfunc] sub-iterators grouped by value of keyfunc(v)
56+
:func:`groupby` iterable[, key] sub-iterators grouped by value of key(v)
5757
:func:`islice` seq, [start,] stop [, step] elements from seq[start:stop:step] ``islice('ABCDEFG', 2, None) --> C D E F G``
5858
:func:`starmap` func, seq func(\*seq[0]), func(\*seq[1]), ... ``starmap(pow, [(2,5), (3,2), (10,3)]) --> 32 9 1000``
5959
:func:`takewhile` pred, seq seq[0], seq[1], until pred fails ``takewhile(lambda x: x<5, [1,4,6,4,1]) --> 1 4``

Modules/itertoolsmodule.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,9 @@ static PyMethodDef groupby_methods[] = {
174174
};
175175

176176
PyDoc_STRVAR(groupby_doc,
177-
"groupby(iterable[, keyfunc]) -> create an iterator which returns\n\
178-
(key, sub-iterator) grouped by each value of key(value).\n");
177+
"groupby(iterable, key=None) -> make an iterator that returns consecutive\n\
178+
keys and groups from the iterable. If the key function is not specified or\n\
179+
is None, the element itself is used for grouping.\n");
179180

180181
static PyTypeObject groupby_type = {
181182
PyVarObject_HEAD_INIT(NULL, 0)

0 commit comments

Comments
 (0)