numpy.hstack() function is used to stack the sequence of input arrays horizontally (i.e. column wise) to make a single array.
Syntax : numpy.hstack(tup)
tup : [sequence of ndarrays] Tuple containing arrays to be stacked. The arrays must have the same shape along all but the second 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 horizontally 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 4 5 6] [-1 -2 -3 -4 -5 -6]]
- Python | Index of Non-Zero elements in Python list
- Python | Merge Python key values to list
- Reading Python File-Like Objects from C | Python
- Important differences between Python 2.x and Python 3.x with examples
- Python | Convert list to Python array
- Python | Add Logging to Python Libraries
- Python | Add Logging to a Python Script
- Python | Sort Python Dictionaries by Key or Value
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Visualizing O(n) using Python
- Any & All in Python
- chr() in Python
- zip() in Python
- set add() 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 firstname.lastname@example.org. 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.