no data exclution and unique combination.

Ian Kelly ian.g.kelly at gmail.com
Tue Jul 24 21:28:01 CEST 2012


On Jul 24, 2012 12:32 PM, <giuseppe.amatulli at gmail.com> wrote:

> after i need to calculate unique combination in pairs to count the
observations
> and obtain
> (4,3,2)
> (4,5,1)
> (5,4,1)
> (4,4,2)

I don't know about a numpy solution, but this could be achieved by
collections.Counter(zip(a, b)).items(). That gives you:
((4,3),2)
((4,5),1)
Etc.

If you really want triples instead of pair-value pairs, then you would need
to flatten the tuples yourself.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120724/c33cedf7/attachment.html>


More information about the Python-list mailing list