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 dimensi
(tup, *, dtype=None, casting="same_kind")
| 292 | |
| 293 | @array_function_dispatch(_vhstack_dispatcher) |
| 294 | def hstack(tup, *, dtype=None, casting="same_kind"): |
| 295 | """ |
| 296 | Stack arrays in sequence horizontally (column wise). |
| 297 | |
| 298 | This is equivalent to concatenation along the second axis, except for 1-D |
| 299 | arrays where it concatenates along the first axis. Rebuilds arrays divided |
| 300 | by `hsplit`. |
| 301 | |
| 302 | This function makes most sense for arrays with up to 3 dimensions. For |
| 303 | instance, for pixel-data with a height (first axis), width (second axis), |
| 304 | and r/g/b channels (third axis). The functions `concatenate`, `stack` and |
| 305 | `block` provide more general stacking and concatenation operations. |
| 306 | |
| 307 | Parameters |
| 308 | ---------- |
| 309 | tup : sequence of ndarrays |
| 310 | The arrays must have the same shape along all but the second axis, |
| 311 | except 1-D arrays which can be any length. In the case of a single |
| 312 | array_like input, it will be treated as a sequence of arrays; i.e., |
| 313 | each element along the zeroth axis is treated as a separate array. |
| 314 | |
| 315 | dtype : str or dtype |
| 316 | If provided, the destination array will have this dtype. Cannot be |
| 317 | provided together with `out`. |
| 318 | |
| 319 | .. versionadded:: 1.24 |
| 320 | |
| 321 | casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional |
| 322 | Controls what kind of data casting may occur. Defaults to 'same_kind'. |
| 323 | |
| 324 | .. versionadded:: 1.24 |
| 325 | |
| 326 | Returns |
| 327 | ------- |
| 328 | stacked : ndarray |
| 329 | The array formed by stacking the given arrays. |
| 330 | |
| 331 | See Also |
| 332 | -------- |
| 333 | concatenate : Join a sequence of arrays along an existing axis. |
| 334 | stack : Join a sequence of arrays along a new axis. |
| 335 | block : Assemble an nd-array from nested lists of blocks. |
| 336 | vstack : Stack arrays in sequence vertically (row wise). |
| 337 | dstack : Stack arrays in sequence depth wise (along third axis). |
| 338 | column_stack : Stack 1-D arrays as columns into a 2-D array. |
| 339 | hsplit : Split an array into multiple sub-arrays |
| 340 | horizontally (column-wise). |
| 341 | unstack : Split an array into a tuple of sub-arrays along an axis. |
| 342 | |
| 343 | Examples |
| 344 | -------- |
| 345 | >>> import numpy as np |
| 346 | >>> a = np.array((1,2,3)) |
| 347 | >>> b = np.array((4,5,6)) |
| 348 | >>> np.hstack((a,b)) |
| 349 | array([1, 2, 3, 4, 5, 6]) |
| 350 | >>> a = np.array([[1],[2],[3]]) |
| 351 | >>> b = np.array([[4],[5],[6]]) |
searching dependent graphs…