# NumPy Joining Array

## Joining NumPy Arrays

Joining means putting contents of two or more arrays in a single array.

In SQL we join tables based on a key, whereas in NumPy we join arrays by axes.

We pass a sequence of arrays that we want to join to the concatenate() function, along with the axis. If axis is not explicitly passed, it is taken as 0.

### Example

Join two arrays

Try it Yourself »

### Example

Join two 2-D arrays along rows (axis=1):

Try it Yourself »

## Joining Arrays Using Stack Functions

Stacking is same as concatenation, the only difference is that stacking is done along a new axis.

We can concatenate two 1-D arrays along the second axis which would result in putting them one over the other, ie. stacking.

We pass a sequence of arrays that we want to join to the stack() method along with the axis. If axis is not explicitly passed it is taken as 0.

### Example

Try it Yourself »

Stacking Along Rows

NumPy provides a helper function: hstack() to stack along rows.

### Example

Try it Yourself »

## Stacking Along Columns

NumPy provides a helper function: vstack()  to stack along columns.

### Example

Try it Yourself »

## Stacking Along Height (depth)

NumPy provides a helper function: dstack() to stack along height, which is the same as depth.

### Example

Try it Yourself »

## Exercise:

Use a correct NumPy method to join two arrays into a single array.

Start the Exercise