How to concatenate these `numpy`

arrays?

first `np.array`

with a shape `(5,4)`

```
[[ 6487 400 489580 0]
[ 6488 401 492994 0]
[ 6491 408 489247 0]
[ 6491 408 489247 0]
[ 6492 402 499013 0]]
```

second `np.array`

with a shape `(5,)`

```
[ 16. 15. 12. 12. 17. ]
```

final result should be

```
[[ 6487 400 489580 0 16]
[ 6488 401 492994 0 15]
[ 6491 408 489247 0 12]
[ 6491 408 489247 0 12]
[ 6492 402 499013 0 17]]
```

I tried `np.concatenate([array1, array2])`

but i get this error

`ValueError: all the input arrays must have same number of dimensions`

What am I doing wrong?

## Rohit Patel

To use

`np.concatenate`

, we need to extend the second array to`2D`

and then concatenate along`axis=1`

–Alternatively, we can use

`np.column_stack`

that takes care of it –Sample run –

If

`b`

is such that its a`1D`

array of`dtype=object`

with a shape of`(1,)`

, most probably all of the data is contained in the only element in it, we need toflattenit out before concatenating. For that purpose, we can use`np.concatenate`

on it too. Here’s a sample run to make the point clear –