9951 explained code solutions for 126 technologies

python-numpyHow to use zip for Numpy arrays

import numpy as np
a1 = [1,2,3]
a2 = [5,6,7]
za = np.array([arr for arr in zip(a1, a2)])ctrl + c
import numpy as np

load Numpy module for Python


declare Numpy array


first sample array


second sample array

zip(a1, a2)

zips a1 and a2` array

[arr for arr in zip(a1, a2)]

generator that populates resulting za Numpy array