**The numpy hstack function is one of the many functions available in numpy that allows you to do some cool things with arrays****. **The function takes two or more input arrays and stacks them vertically on top of each other, so they are next to each other.

This way, if you have a set of data that has three dimensions (height, width, and color) it will stack all the height rows on top of each other first, then stack all the width rows on top of those, then finally stack all the color channels on top of those with the help of numpy hstack function.

This can be useful for taking an array that has been divided into smaller ones by hsplit(), putting them back together again – but this time horizontally instead!

The numpy.hstack() function is used to stack the sequence of input arrays horizontally (i.e. column wise) to make a single array. This article explains how it can be done with an example and its applications in data analytics, signal processing, image processing etc.

Table of Contents

## Related Topics

### Numpy Hstack Python Syntax

`numpy.hstack(tup) `

### Parameters

**tup: sequence of ndarrays**

Except for 1-D arrays, which can be any length, the arrays must have the same shape along all axes except the second.

### Returns

**Stacked: ndarray**

The array created by stacking the arrays provided.

Letâ€™s have a look at an example.

### Example Code

```
import numpy as np
array1 = np.array([ 'a', 1, 'b', 2] )
print ("Input Array 1 : \n", array1)
array2 = np.array([ 'c', 3, 'd', 4] )
print ("Input Array 2 : \n", array2)
output_array = np.hstack((array1, array2))
print ("Stacked Array:\n ", output_array)
```

### Output

## Conclusion

The hstack() function is one of the many functions available in numpy that allows you to do some cool things with arrays. The function takes two or more input arrays and stacks them vertically on top of each other, so they are next to each other. You can also use an asterisk for stacking multiple arrays on top of one another, like this: *hstack((arr1, arr2))*