Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #4013
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.glorb.com!news2.glorb.com!news-out.octanews.net!indigo.octanews.net!auth.beige.octanews.com.POSTED!not-for-mail |
|---|---|
| From | Paul Rubin <no.email@nospam.invalid> |
| Newsgroups | comp.lang.python |
| Subject | Re: Simple map/reduce utility function for data analysis |
| References | <967b61ce-5641-484a-bd76-5a09bd4247e0@w9g2000prg.googlegroups.com> |
| Date | Mon, 25 Apr 2011 19:42:17 -0700 |
| Message-ID | <7xei4pohrq.fsf@ruckus.brouhaha.com> (permalink) |
| Organization | Nightsong/Fort GNOX |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
| Cancel-Lock | sha1:zUbA39hHHjmwLGDuO1FD3WoPjIo= |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Lines | 11 |
| NNTP-Posting-Date | 25 Apr 2011 21:42:17 CDT |
| X-Complaints-To | abuse@octanews.net |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:4013 |
Show key headers only | View raw
Raymond Hettinger <python@rcn.com> 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)):
d[key].append(value)
...
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Simple map/reduce utility function for data analysis Raymond Hettinger <python@rcn.com> - 2011-04-25 16:48 -0700
Re: Simple map/reduce utility function for data analysis Paul Rubin <no.email@nospam.invalid> - 2011-04-25 19:42 -0700
Re: Simple map/reduce utility function for data analysis Raymond Hettinger <python@rcn.com> - 2011-04-26 11:12 -0700
Re: Simple map/reduce utility function for data analysis Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-04-26 02:52 +0000
csiph-web