numpy.vstack() function is used to stack the sequence of input arrays vertically to make a single array.
Syntax : numpy.vstack(tup)
tup : [sequence of ndarrays] Tuple containing arrays to be stacked. The arrays must have the same shape along all but the first axis.
Return : [stacked ndarray] The stacked array of the input arrays.
Code #1 :
1st Input array : [1 2 3] 2nd Input array : [4 5 6] Output vertically stacked array: [[1 2 3] [4 5 6]]
Code #2 :
1st Input array : [[ 1 2 3] [-1 -2 -3]] 2nd Input array : [[ 4 5 6] [-4 -5 -6]] Output stacked array : [[ 1 2 3] [-1 -2 -3] [ 4 5 6] [-4 -5 -6]]
- Important differences between Python 2.x and Python 3.x with examples
- Python | Merge Python key values to list
- Reading Python File-Like Objects from C | Python
- Python | Index of Non-Zero elements in Python list
- Python | Convert list to Python array
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Add Logging to a Python Script
- Python | Add Logging to Python Libraries
- Python | Sort Python Dictionaries by Key or Value
- Python | Visualizing O(n) using Python
- SHA in Python
- Python Set | pop()
- Any & All in Python
- max() and min() in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.