[Numpy-discussion] Tuple outer product?

Alan G Isaac aisaac@american....
Fri Sep 25 13:02:55 CDT 2009


On 9/25/2009 1:45 PM, Mads Ipsen wrote:
> Is there a numpy operation on two arrays, say [1,2,3] and [4,5,6], that
> will yield:
>
> [[(1,4),(1,5),(1,6)],[(2,4),(2,5),(2,6)],[(3,4),(3,5),(3,6)]]


>>> from itertools import product
>>> list(product([1,2,3],[4,5,6]))
[(1, 4), (1, 5), (1, 6), (2, 4), (2, 5), (2, 6), (3, 4), (3, 5), (3, 6)]

Alan Isaac


More information about the NumPy-Discussion mailing list