Write a NumPy program to create a Cartesian product of two arrays into single array of 2D points.
import numpy as np x = np.array([1,2,3]) y = np.array([4,5]) result = np.transpose([np.tile(x, len(y)), np.repeat(y, len(x))]) print(result)
Sample Output:
[[1 4] [2 4] [3 4] [1 5] [2 5] [3 5]]
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer