Alan:

The equivalent of that in my current draft would be group_by(keys, values),
which is shorthand for group_by(keys).group(values); a optional values
argument to the constructor of GroupBy is directly bound to return an
iterable over the grouped values; but we often want to bind different value
objects, with different operations, for the same set of keys, so it is
convenient to be able to delay the binding of the values argument. Also,
the third argument to group_by is an optional reduction function.


On Sun, Jan 26, 2014 at 6:57 PM, Alan G Isaac <alan.is...@gmail.com> wrote:

> On 1/26/2014 12:02 PM, Stéfan van der Walt wrote:
> >   what would the output of
> >
> > ``group_by((key1, key2))``
>
>
> I'd expect something named "groupby" to behave as below.
> Alan
>
> def groupby(seq, key):
>    from collections import defaultdict
>    groups = defaultdict(list)
>    for item in seq:
>      groups[key(item)].append(item)
>    return groups
>
> print groupby(range(20), lambda x: x%2)
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to