Q:

Write a NumPy program to stack arrays in sequence vertically

0

Write a NumPy program to stack arrays in sequence vertically.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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.vstack((x,y))
print("\nStack arrays in sequence vertically:")
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 vertically:
[[ 0  1  2]
 [ 3  4  5]
 [ 6  7  8]
 [ 0  3  6]
 [ 9 12 15]
 [18 21 24]]

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now