Combine arrays with concatenate(), vstack(), hstack(), stack(), and column_stack().
Joining combines multiple arrays along an existing or newly created axis. `np.vstack` stacks vertically (rows); `np.hstack` stacks horizontally (columns).
`vstack` is stacking plates on top of each other into a tall tower (row stack). `hstack` is pushing two tables side-by-side to make a wider table (column stack).
`np.concatenate([a, b], axis=0)` is the general function. `vstack` forces 2D vertical stacking; `hstack` joins along column dimensions.
v = np.vstack([a, b]); h = np.hstack([a, b])np.concatenate(a, b) # Missing list/tuple wrappernp.concatenate([a, b])Arrays to join must be passed as a single list or tuple `[a, b]` as the first argument.
Solve the objective below using NumPy vectorized syntax
Create `a = np.array([1, 2])` and `b = np.array([3, 4])`, stack them vertically with `np.vstack([a, b])`, and print.
[[1 2]
[3 4]]