[Numpy-discussion] Numpy Enhancement Proposal: group_by functionality

Alan G Isaac alan.isaac at gmail.com
Sun Jan 26 12:57:11 EST 2014

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.

def groupby(seq, key):
   from collections import defaultdict
   groups = defaultdict(list)
   for item in seq:
   return groups

print groupby(range(20), lambda x: x%2)

More information about the NumPy-Discussion mailing list