Python Practice › NumPy Programs › Program 63
1-D arrays as columns
Write a NumPy program to combine two 1-D arrays as columns of a 2-D array.
Input
(3, 8, 5), (4, 0, 7)
Output
[[3 4] [8 0] [5 7]]
Approach
np.column_stack.
Solution
import numpy as npprint(np.column_stack(((3, 8, 5), (4, 0, 7))))Output
[[3 4] [8 0] [5 7]]
Learn the concept
New to this topic? Read the lesson, then come back.