Q:

Write a NumPy program to stack 1-D arrays as columns wise

0

Write a NumPy program to stack 1-D arrays as columns wise.

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.array((1,2,3))
y = np.array((2,3,4))
print("Array-1")
print(x)
print("Array-2")
print(y)
new_array =  np.column_stack((x, y))
print("\nStack 1-D arrays as columns wise:")
print(new_array)

Sample Output:

Original arrays:
Array-1
[1 2 3]
Array-2
[2 3 4]

Stack 1-D arrays as columns wise:
[[1 2]
 [2 3]
 [3 4]]

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