Numeric/Numarray equivalent to zip ?
Peter Otten
__peter__ at web.de
Sun May 1 03:03:36 EDT 2005
George Sakkis wrote:
> What's the fastest and most elegant equivalent of zip() in
> Numeric/Numarray between two equally sized 1D arrays ? That is, how to
> combine two (N,)-shaped arrays to one (N,2) (or (2,N)) shaped ? I
> expect the fastest and the most elegant idiom to be identical, as it is
> usually the case in this excellent library, but if not, both would be
> useful to know. Thanks,
>>> import Numeric as nu
>>> a = nu.array(range(3))
>>> nu.array([a, a])
array([[0, 1, 2],
[0, 1, 2]])
>>> nu.transpose(nu.array([a, a]))
array([[0, 0],
[1, 1],
[2, 2]])
Or am I missing something? As to speed, it seems to be the fastest to
write...
Peter
More information about the Python-list
mailing list