Exercise 7

Stack 2 numpy arrays vertically, i.e. 2 arrays with the same last dimension (same number of columns).

Solution

import numpy as np

A = np.array([[1 , 2],
[3 , 4]
])

B = np.array([[5 , 6],
[7 , 8]
])

C = np.vstack((A, B))

print(C)
"""
attach:
[[1 2]
[3 4]
[5 6]
[7 8]]
"""
Younes Derfoufi
my-courses.net

Leave a Reply