How to Concatenate Arrays in Python

A retail client sent me first-quarter sales for two store regions as separate NumPy arrays and wanted one array for a report. That’s the everyday reason to concatenate arrays in Python.

The obvious east + west doesn’t join anything; on NumPy arrays, + adds values position by position.

Quick answer: pass the arrays as a tuple to np.concatenate(). It returns one new array with all the values in order:

both = np.concatenate((east, west))   # 3 + 3 -> 6 values

In this tutorial, I’ll join 1D and 2D arrays, compare the stack helpers, cover the array module and fix common errors. I ran everything on Python 3.12.5 with NumPy 2.5.3.

How do you concatenate two NumPy arrays with np.concatenate()?

The sample store_sales.py holds East and West monthly sales in USD for January-March 2026.

import numpy as np
from store_sales import east, west

both = np.concatenate((east, west))
print("Joined:", both)
print(f"Q1 total: ${both.sum():,.2f}")

print("east + west:", east + west)

Output:

Joined: [18250.   19740.5  21115.25 15980.75 17420.   16805.4 ]
Q1 total: $109,311.90
east + west: [34230.75 37160.5  37920.65]
Command Prompt output of Python np.concatenate joining two NumPy sales arrays into one six-value array
np.concatenate((east, west)) gives six values; east + west gives three sums.

The joined array holds six values totaling $109,311.90, while + returned three sums.

Comparing concatenate with np.append? I cover that in NumPy concatenate vs append.

Concatenate 2D arrays along axis 0 and axis 1

Now each region is 2D (row 0 sales, row 1 orders), and axis sets the direction.

import numpy as np
from store_sales import east, west

east_q1 = np.array([[18250, 19740, 21115],
                    [ 4120,  4385,  4630]])  # sales, orders
west_q1 = np.array([[15980, 17420, 16805],
                    [ 3710,  3955,  3890]])

rows = np.concatenate((east_q1, west_q1), axis=0)
cols = np.concatenate((east_q1, west_q1), axis=1)
flat = np.concatenate((east_q1, west_q1), axis=None)
print("axis=0 ->", rows.shape)
print("axis=1 ->", cols.shape)
print("axis=None ->", flat.shape)
print(cols)

Output:

axis=0 -> (4, 3)
axis=1 -> (2, 6)
axis=None -> (12,)
[[18250 19740 21115 15980 17420 16805]
 [ 4120  4385  4630  3710  3955  3890]]
Command Prompt output of Python np.concatenate on 2D arrays with axis=0, axis=1 and axis=None shapes
axis=0 stacks rows to (4, 3), axis=1 puts columns side by side as (2, 6).

axis=0 is the default. axis=None flattens both inputs into 12 values.

New to 2D arrays? Start with how to initialize a 2D array in Python.

Which stack function joins NumPy arrays: stack, vstack or hstack?

These helpers wrap concatenate with a preset axis. Here they are on the 1D sample:

import numpy as np
from store_sales import east, west

print("stack:  ", np.stack((east, west)).shape)
print("vstack: ", np.vstack((east, west)).shape)
print("hstack: ", np.hstack((east, west)).shape)

Output:

stack:   (2, 3)
vstack:  (2, 3)
hstack:  (6,)

np.stack() adds a new axis, giving (2, 3). vstack treats 1D inputs as rows, and hstack matches concatenate.

Concatenate arrays from the built-in array module

Without NumPy, the array module’s + really joins, and extend() joins in place:

from array import array

march = array("d", [1299.99, 849.50])
april = array("d", [1525.00, 975.25])

combined = march + april
print(combined)

march.extend(april)
print("After extend:", len(march), "items")

try:
    march + array("i", [10, 20])
except TypeError as err:
    print("TypeError:", err)

Output:

array('d', [1299.99, 849.5, 1525.0, 975.25])
After extend: 4 items
TypeError: bad argument type for built-in operation
Command Prompt output of Python array module arrays joined with + and extend and a TypeError for mixed typecodes
Two array('d') objects join; mixing typecodes raises a TypeError.

Both arrays must share a typecode.

See the difference between arrays and lists. For plain lists, use these ways to concatenate multiple lists.

Common errors when concatenating NumPy arrays

import numpy as np
from store_sales import east, west

monthly = np.array([[18250, 19740, 21115]])
try:
    np.concatenate((monthly, west.reshape(1, 3)[:, :2]), axis=0)
except ValueError as err:
    print("ValueError:", err)

try:
    np.concatenate((np.array(5), np.array(7)))
except ValueError as err:
    print("ValueError:", err)

units = np.array([120, 95])
mixed = np.concatenate((units, east))
print(mixed.dtype, mixed[:3])

Output:

ValueError: all the input array dimensions except for the concatenation axis must match exactly, but along dimension 1, the array at index 0 has size 3 and the array at index 1 has size 2
ValueError: zero-dimensional arrays cannot be concatenated
float64 [  120.    95. 18250.]
Command Prompt output of Python np.concatenate ValueError dimension mismatch and zero-dimensional arrays cannot be concatenated
A size mismatch on axis 1 and two 0-D arrays each raise a ValueError; int plus float becomes float64.

Every axis except the join axis must match, so reshape first.

0-D scalars have no axis; wrap them with np.atleast_1d().

Mixing ints and floats upcasts the result to float64. If your data starts as a list, convert the list to an array with the dtype you want.

Ways to concatenate arrays in Python compared

ApproachWorks onWhen I use it
np.concatenate((a, b))NumPy arraysDefault; any axis
np.stack((a, b))Same-shape NumPy arraysNeed a new axis
np.vstack / np.hstackNumPy arraysReadable rows/columns
a + b, a.extend(b)array.arrayNo NumPy installed

Adding one value at a time instead? That’s appending to an array in Python.

More array basics you’ll use:

Frequently asked questions

How do I concatenate two arrays in Python?

Use np.concatenate((a, b)) for NumPy arrays and a + b for array.array.

Why does + not concatenate NumPy arrays?

NumPy treats + as element-wise addition, so equal-length arrays return their sums.

What does axis do in np.concatenate?

axis=0 joins rows, axis=1 joins columns, and axis=None flattens the inputs first.

What’s the difference between np.stack and np.concatenate?

concatenate joins along an existing axis; stack creates a new one.

Does np.concatenate modify the original arrays?

No. It returns a new array and leaves the inputs unchanged.

Where is np.concatenate documented?

See numpy.concatenate in the NumPy docs.