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

np.array

declare Numpy array

a1

first sample array

a2

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