Write a NumPy program to create a Cartesian product of two arrays into single array of 2D points
- برمجة بايثون
- 2021-09-13
- mhanasmh00489829403
الأجوبة
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]]
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال