numpy.vstack


Advertisements

Variants of numpy.stack function to stack so as to make a single array vertically.

Example

import numpy as np 
a = np.array([[1,2],[3,4]]) 

print 'First array:' 
print a 
print '\n'  
b = np.array([[5,6],[7,8]]) 

print 'Second array:' 
print b 
print '\n'

print 'Vertical stacking:' 
c = np.vstack((a,b)) 
print c

It would produce the following output −

First array:
[[1 2]
 [3 4]]

Second array:
[[5 6]
 [7 8]]

Vertical stacking:
[[1 2]
 [3 4]
 [5 6]
 [7 8]]
numpy_array_manipulation.htm
Advertisements