append two 1d arrays python 1

append two 1d arrays python

numpy.r_[a, a],
numpy.stack([a, a]).reshape(-1),
numpy.hstack([a, a]),
numpy.concatenate([a, a])

Here is what the above code is Doing:
1. numpy.r_[a, a]
– This is a special numpy function that takes a sequence of arrays and stacks them along the first axis.
– The first axis is the rows, so this is stacking the arrays on top of each other.
– This is the same as numpy.vstack([a, a])
2. numpy.stack([a, a]).reshape(-1)
– This is stacking the arrays along a new axis, then reshaping the result to remove that axis.
– This is the same as numpy.hstack([a, a])
3. numpy.hstack([a, a])
– This is stacking the arrays along the second axis.
– The second axis is the columns, so this is stacking the arrays side by side.
4. numpy.concatenate([a, a])
– This is concatenating the arrays along the first axis.
– This is the same as numpy.vstack([a, a])

Similar Posts