The column_stack()
function in NumPy is used to stack or arrange 1-D
input arrays as columns into a 2-D
array.
numpy.column_stack(tup)
The column_stack()
function takes a parameter value.
tup
: This represents a sequence of the 1-D
or 2-D
arrays to be stacked.The column_stack()
function returns an array formed by stacking the input arrays.
import numpy as np# creating input arraysa = np.array([1, 2, 3, 4])b = np.array([5, 6, 7, 8])# stacking the arraysstacked_array=np.column_stack((a,b))# printing the stacked arrayprint(stacked_array)
numpy
module.a
and b
using the array()
function.a
and b
using the column_stack()
function. The result is assigned to a variable, stacked_array
.stacked_array
.