Did I find the right examples for you? yes no

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]}

    See Also:
        ``countby``
    """

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


src/l/o/logic-0.1.10/logpy/core.py   logic(Download)
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, [])
    bad  = groups.get(False, [])

src/m/u/multipledispatch-0.4.0/multipledispatch/conflict.py   multipledispatch(Download)
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:

src/m/u/multipledispatch-HEAD/multipledispatch/conflict.py   multipledispatch(Download)
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:

src/m/p/mplfacet-HEAD/mplfacet/facet.py   mplfacet(Download)
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)

src/m/p/mplfacet-HEAD/mplfacet/tests/test_util.py   mplfacet(Download)
import numpy as np
 
from ..util import groupby
 
 
def check_groupby(*arrs):
    ct = 0
    last = None
    for key, inds in groupby(*arrs):