Did I find the right examples for you? yes no

# util.groupby

All Samples(10)  |  Call(5)  |  Derive(0)  |  Import(5)
```Group a collection by a key function

>>> names = ['Alice', 'Bob', 'Charlie', 'Dan', 'Edith', 'Frank']
>>> groupby(len, names)
{3: ['Bob', 'Dan'], 5: ['Alice', 'Edith', 'Frank'], 7: ['Charlie']}

>>> iseven = lambda x: x % 2 == 0
>>> groupby(iseven, [1, 2, 3, 4, 5, 6, 7, 8])
{False: [1, 3, 5, 7], True: [2, 4, 6, 8]}
(more...)
```

```        def groupby(func, seq):
""" Group a collection by a key function

>>> names = ['Alice', 'Bob', 'Charlie', 'Dan', 'Edith', 'Frank']
>>> groupby(len, names)
{3: ['Bob', 'Dan'], 5: ['Alice', 'Edith', 'Frank'], 7: ['Charlie']}

>>> iseven = lambda x: x % 2 == 0
>>> groupby(iseven, [1, 2, 3, 4, 5, 6, 7, 8])
{False: [1, 3, 5, 7], True: [2, 4, 6, 8]}

``countby``
"""

d = dict()
for item in seq:
key = func(item)
if key not in d:
d[key] = list()
d[key].append(item)
return d
```

```import itertools as it
from util import transitive_get as walk
from util import deep_transitive_get as walkstar
from util import (assoc, unique, dicthash, interleave, take, evalt,
groupby, index)
```
```        EarlyGoalError
"""
groups = groupby(earlysafe, goals)
good = groups.get(True, [])
```

```from .util import _toposort, groupby

class AmbiguityWarning(Warning):
pass

```
```    signatures = list(map(tuple, signatures))
edges = [(a, b) for a in signatures for b in signatures if edge(a, b)]
edges = groupby(lambda x: x[0], edges)
for s in signatures:
if s not in edges:
```

```from .util import _toposort, groupby

class AmbiguityWarning(Warning):
pass

```
```    signatures = list(map(tuple, signatures))
edges = [(a, b) for a in signatures for b in signatures if edge(a, b)]
edges = groupby(lambda x: x[0], edges)
for s in signatures:
if s not in edges:
```

```from matplotlib.axes import Axes

from .util import subplots, groupby

```
```        axes = self._subplots
used = []
for k, ind in groupby(*self._keys):
a = axes[self._pick_axes(k)]
used.append(a)
```

```import numpy as np