The row_stack()
function in NumPy is used to stack or arrange arrays in sequence vertically (row-wise).
numpy.row_stack(tup)
The row_stack()
function takes a single parameter value, tup
, which represents the arrays that have the same shape along all the axes, except for the first axis.
The row_stack()
function returns at least a 2-D
array that is formed by stacking the given arrays vertically.
import numpy as np# creating input arraysa = np.array([1, 2, 3, 4, 5])b = np.array([6, 7, 8, 9, 10])# stacking the arrays verticallystacked_array = np.row_stack((a, b))# printing the new arrayprint(stacked_array)
numpy
module.a
and b
, using the array()
function.a
and b
using the row_stack()
function. The result is assigned to a variable, stacked_array
.stacked_array
.