Re: Simple map/reduce utility function for data analysis

2011-04-26 Thread Raymond Hettinger
On Apr 25, 7:42 pm, Paul Rubin wrote: > Raymond Hettinger writes: > > Here's a handy utility function for you guys to play with: > >    http://code.activestate.com/recipes/577676/ > > Cute, but why not use collections.defaultdict for the return dict? > Untested: My first draft had a defaultdict

Re: Simple map/reduce utility function for data analysis

2011-04-25 Thread Steven D'Aprano
On Mon, 25 Apr 2011 16:48:42 -0700, Raymond Hettinger wrote: > Here's a handy utility function for you guys to play with: > > http://code.activestate.com/recipes/577676/ Nice. That's similar to itertools.groupby except that it consolidates all the equal key results into one list, instead

Re: Simple map/reduce utility function for data analysis

2011-04-25 Thread Paul Rubin
Raymond Hettinger writes: > Here's a handy utility function for you guys to play with: > http://code.activestate.com/recipes/577676/ Cute, but why not use collections.defaultdict for the return dict? Untested: d = defaultdict(list) for key,value in ifilter(bool,imap(mapper, data)):

Simple map/reduce utility function for data analysis

2011-04-25 Thread Raymond Hettinger
Here's a handy utility function for you guys to play with: http://code.activestate.com/recipes/577676/ Raymond twitter: @raymondh -- http://mail.python.org/mailman/listinfo/python-list