Write a NumPy program to stack arrays in sequence horizontally (column wise).
import numpy as np print("\nOriginal arrays:") x = np.arange(9).reshape(3,3) y = x*3 print("Array-1") print(x) print("Array-2") print(y) new_array = np.hstack((x,y)) print("\nStack arrays in sequence horizontally:") print(new_array)
Sample Output:
Original arrays: Array-1 [[0 1 2] [3 4 5] [6 7 8]] Array-2 [[ 0 3 6] [ 9 12 15] [18 21 24]] Stack arrays in sequence horizontally: [[ 0 1 2 0 3 6] [ 3 4 5 9 12 15] [ 6 7 8 18 21 24]]
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