Write a NumPy program to join a sequence of arrays along a new axis
- برمجة بايثون
- 2021-09-13
- mhanasmh00489829403
الأجوبة
import numpy as np
x = np.array([1, 2, 3])
y = np.array([2, 3, 4])
print("Original arrays:")
print(x)
print(y)
print("Sequence of arrays along a new axis:")
print(np.vstack((x, y)))
x = np.array([[1], [2], [3]])
y = np.array([[2], [3], [4]])
print("\nOriginal arrays:")
print(x)
print()
print(y)
print("Sequence of arrays along a new axis:")
print(np.vstack((x, y)))
Sample Output:
Original arrays: [1 2 3] [2 3 4] Sequence of arrays along a new axis: [[1 2 3] [2 3 4]] Original arrays: [[1] [2] [3]] [[2] [3] [4]] Sequence of arrays along a new axis: [[1] [2] [3] [2] [3] [4]]
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال