Exercise 6
Stack 2 numpy marices horizontally, i.e. 2 arrays having the same 1st dimension (same number of rows).
Solution
import numpy as np
A = np.array([[1 , 2],
[6 , 7]])
B = np.array([[3 , 4 , 5],
[8 , 9 , 10]])
C = np.hstack((A, B))
print(C)
"""
attach:
[[ 1 2 3 4 5]
[ 6 7 8 9 10]]
"""
Younes Derfoufi
my-courses.net
my-courses.net