Stack arrays in sequence vertically (row wise). This is equivalent to concatenation along the first axis after 1-D arrays of shape `(N,)` have been reshaped to `(1,N)`. Rebuilds arrays divided by `vsplit`. This function makes most sense for arrays with up to 3 dimensions. For
(tup, *, dtype=None, casting="same_kind")
| 218 | |
| 219 | @array_function_dispatch(_vhstack_dispatcher) |
| 220 | def vstack(tup, *, dtype=None, casting="same_kind"): |
| 221 | """ |
| 222 | Stack arrays in sequence vertically (row wise). |
| 223 | |
| 224 | This is equivalent to concatenation along the first axis after 1-D arrays |
| 225 | of shape `(N,)` have been reshaped to `(1,N)`. Rebuilds arrays divided by |
| 226 | `vsplit`. |
| 227 | |
| 228 | This function makes most sense for arrays with up to 3 dimensions. For |
| 229 | instance, for pixel-data with a height (first axis), width (second axis), |
| 230 | and r/g/b channels (third axis). The functions `concatenate`, `stack` and |
| 231 | `block` provide more general stacking and concatenation operations. |
| 232 | |
| 233 | ``np.row_stack`` is an alias for `vstack`. They are the same function. |
| 234 | |
| 235 | Parameters |
| 236 | ---------- |
| 237 | tup : sequence of ndarrays |
| 238 | The arrays must have the same shape along all but the first axis. |
| 239 | 1-D arrays must have the same length. |
| 240 | |
| 241 | dtype : str or dtype |
| 242 | If provided, the destination array will have this dtype. Cannot be |
| 243 | provided together with `out`. |
| 244 | |
| 245 | .. versionadded:: 1.24 |
| 246 | |
| 247 | casting : {'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional |
| 248 | Controls what kind of data casting may occur. Defaults to 'same_kind'. |
| 249 | |
| 250 | .. versionadded:: 1.24 |
| 251 | |
| 252 | Returns |
| 253 | ------- |
| 254 | stacked : ndarray |
| 255 | The array formed by stacking the given arrays, will be at least 2-D. |
| 256 | |
| 257 | See Also |
| 258 | -------- |
| 259 | concatenate : Join a sequence of arrays along an existing axis. |
| 260 | stack : Join a sequence of arrays along a new axis. |
| 261 | block : Assemble an nd-array from nested lists of blocks. |
| 262 | hstack : Stack arrays in sequence horizontally (column wise). |
| 263 | dstack : Stack arrays in sequence depth wise (along third axis). |
| 264 | column_stack : Stack 1-D arrays as columns into a 2-D array. |
| 265 | vsplit : Split an array into multiple sub-arrays vertically (row-wise). |
| 266 | |
| 267 | Examples |
| 268 | -------- |
| 269 | >>> a = np.array([1, 2, 3]) |
| 270 | >>> b = np.array([4, 5, 6]) |
| 271 | >>> np.vstack((a,b)) |
| 272 | array([[1, 2, 3], |
| 273 | [4, 5, 6]]) |
| 274 | |
| 275 | >>> a = np.array([[1], [2], [3]]) |
| 276 | >>> b = np.array([[4], [5], [6]]) |
| 277 | >>> np.vstack((a,b)) |