0 votes
in Python by
explain numpy.vstack() in Python

1 Answer

0 votes
by

numpy.vstack() in Python

The numpy.vstack() function stacks the arrays in a sequence vertically (row wise).

Syntax

numpy.vstack(tup)

Parameter

tup: This parameter represents the sequence of ‘ndarrays’ where the arrays must have the same shape along all except the first axis.

Return

This function returns the array formed by stacking the given arrays, will be at least 2-D.

Example 1

# Python program explaining
# numpy.vstack() function
import numpy as np
inp_array1 = np.array([[ 11, 12, 13], [ -11, -12, -13]] )
print ("Input array: ", inp_array1) 
inp_array2 = np.array([[ 14, 15, 16], [ -14, -15, -16]] )
print ("Input array: ", inp_array2) 
#stacks the arrays in a sequence vertically (row wise)
out_array = np.vstack((inp_array1, inp_array2))
print ("Output array: ", out_array)

Output

Input array:  [[ 11  12  13]
[-11 -12 -13]]
Input array:  [[ 14  15  16]
[-14 -15 -16]]
Output array:  [[ 11  12  13]
[-11 -12 -13]
[ 14  15  16]
[-14 -15 -16]]

Related questions

0 votes
asked May 19, 2022 in Python by john ganales
0 votes
asked May 19, 2022 in Python by john ganales
...