# numpy.hstack¶

`numpy.``hstack`(tup)[source]

Stack arrays in sequence horizontally (column wise).

This is equivalent to concatenation along the second axis, except for 1-D arrays where it concatenates along the first axis. Rebuilds arrays divided by `hsplit`.

This function makes most sense for arrays with up to 3 dimensions. For instance, for pixel-data with a height (first axis), width (second axis), and r/g/b channels (third axis). The functions `concatenate`, `stack` and `block` provide more general stacking and concatenation operations.

Parameters
tupsequence of ndarrays

The arrays must have the same shape along all but the second axis, except 1-D arrays which can be any length.

Returns
stackedndarray

The array formed by stacking the given arrays.

`concatenate`

Join a sequence of arrays along an existing axis.

`stack`

Join a sequence of arrays along a new axis.

`block`

Assemble an nd-array from nested lists of blocks.

`vstack`

Stack arrays in sequence vertically (row wise).

`dstack`

Stack arrays in sequence depth wise (along third axis).

`column_stack`

Stack 1-D arrays as columns into a 2-D array.

`hsplit`

Split an array into multiple sub-arrays horizontally (column-wise).

Examples

```>>> a = np.array((1,2,3))
>>> b = np.array((2,3,4))
>>> np.hstack((a,b))
array([1, 2, 3, 2, 3, 4])
>>> a = np.array([,,])
>>> b = np.array([,,])
>>> np.hstack((a,b))
array([[1, 2],
[2, 3],
[3, 4]])
```
{"ft_lang_label":"__label__en","ft_lang_prob":0.72973424,"math_prob":0.94005984,"size":1318,"snap":"2023-14-2023-23","text_gpt3_token_len":346,"char_repetition_ratio":0.15144597,"word_repetition_ratio":0.01980198,"special_character_ratio":0.28755692,"punctuation_ratio":0.17266187,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9880128,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-05-29T21:32:46Z\",\"WARC-Record-ID\":\"<urn:uuid:93b20b9e-76d0-418e-8bb9-1b16171a6bd6>\",\"Content-Length\":\"20809\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:fda2c662-2711-40db-a4cc-cf3e78415d4a>\",\"WARC-Concurrent-To\":\"<urn:uuid:dd94fca0-01a6-41c8-b90c-27d64e295fe2>\",\"WARC-IP-Address\":\"172.67.185.160\",\"WARC-Target-URI\":\"https://numpy.org/doc/1.20/reference/generated/numpy.hstack.html\",\"WARC-Payload-Digest\":\"sha1:AW3KX62JH6DIELNQ6WRPDSNV3HVYKNPZ\",\"WARC-Block-Digest\":\"sha1:4RCZP2UO7PEPC5IFP343II7OB4B6OAP4\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-23/CC-MAIN-2023-23_segments_1685224644913.39_warc_CC-MAIN-20230529205037-20230529235037-00083.warc.gz\"}"}