When I was working on a data science project, I needed to combine multiple NumPy arrays. I realized that many Python developers get confused between NumPy’s concatenate and append functions – both seem to do similar things, but there are crucial differences between them.
In this article, I’ll cover how to use both methods, when each is appropriate, and some practical examples to help you make the right choice in your Python code.
NumPy Concatenate
NumPy’s concatenate function is one of the most efficient ways to join arrays together. I use it frequently when I need precise control over how my arrays are combined.
Read NumPy Sum of Squares in Python
Basic Syntax of numpy.concatenate()
import numpy as np
# Basic syntax
np.concatenate((arr1, arr2, ...), axis=0)The concatenate function takes a sequence of arrays as its first argument and joins them along the specified axis. By default, it joins along axis=0 (rows).
Concatenate 1D Arrays
NumPy allows easy combination of 1D arrays using the concatenate() function.
import numpy as np
# Create two 1D arrays
states_west = np.array(['California', 'Oregon', 'Washington'])
states_east = np.array(['New York', 'Massachusetts', 'Florida'])
# Concatenate the arrays
all_states = np.concatenate((states_west, states_east))
print(all_states)Output:
['California' 'Oregon' 'Washington' 'New York' 'Massachusetts' 'Florida']I executed the above example code and added the screenshot below.

This is a simple way to merge multiple 1D arrays into a single unified array.
Check out Check if NumPy Array is Empty in Python
Concatenate 2D Arrays
Working with 2D arrays is where concatenate shines:
import numpy as np
# Population data (in millions) for Western and Eastern states
west_data = np.array([[39.5, 4.2, 7.6], # California, Oregon, Washington
[271, 98, 176]]) # Area (thousand sq mi)
east_data = np.array([[19.8, 7.0, 21.5], # New York, Massachusetts, Florida
[54, 10, 66]]) # Area (thousand sq mi)
# Concatenate along rows (axis=0)
all_data_rows = np.concatenate((west_data, east_data), axis=0)
print("Concatenated along rows:")
print(all_data_rows)
# Concatenate along columns (axis=1)
all_data_cols = np.concatenate((west_data, east_data), axis=1)
print("\nConcatenated along columns:")
print(all_data_cols)Output:
Concatenated along rows:
[[ 39.5 4.2 7.6]
[271. 98. 176. ]
[ 19.8 7. 21.5]
[ 54. 10. 66. ]]
Concatenated along columns:
[[ 39.5 4.2 7.6 19.8 7. 21.5]
[271. 98. 176. 54. 10. 66. ]]I executed the above example code and added the screenshot below.

When concatenating along axis=0, the function stacks arrays on top of each other. With axis=1, it combines them side by side.
Read np.round() Function in Python
NumPy Append
The append function is simpler but has some important limitations that I’ve learned to watch out for.
Basic Syntax of numpy.append()
import numpy as np
# Basic syntax
np.append(arr1, arr2, axis=None)The key thing to remember is that append flattens arrays by default (when axis=None).
Append 1D Arrays
You can use NumPy’s append() function to add elements from one 1D array to another.
import numpy as np
# Create two 1D arrays of US cities
cities_west = np.array(['Los Angeles', 'Seattle', 'Denver'])
cities_east = np.array(['Chicago', 'New York', 'Miami'])
# Append the arrays
all_cities = np.append(cities_west, cities_east)
print(all_cities)Output:
['Los Angeles' 'Seattle' 'Denver' 'Chicago' 'New York' 'Miami']I executed the above example code and added the screenshot below.

This looks similar to concatenate, but the behavior changes drastically with 2D arrays.
Read AttributeError: ‘numpy.ndarray’ object has no attribute ‘split’ in Python
Append 2D Arrays
NumPy’s append() function allows you to combine 2D arrays by flattening or appending along a specific axis.
import numpy as np
# Temperature data (°F) for cities
west_temps = np.array([[75, 65, 80], # LA, Seattle, Denver
[60, 55, 65]]) # Night temps
east_temps = np.array([[70, 75, 85], # Chicago, NYC, Miami
[65, 70, 75]]) # Night temps
# With axis=None (default), arrays are flattened first
flattened = np.append(west_temps, east_temps)
print("Flattened result:")
print(flattened)
# With axis specified
appended_rows = np.append(west_temps, east_temps, axis=0)
print("\nAppended along rows (axis=0):")
print(appended_rows)
appended_cols = np.append(west_temps, east_temps, axis=1)
print("\nAppended along columns (axis=1):")
print(appended_cols)It’s a flexible way to merge data matrices, whether you’re stacking them row-wise, column-wise, or into a single flat array.
Check out np.abs() in Python Numpy
Key Differences Between Concatenate and Append
After years of working with NumPy, I’ve identified these critical differences:
- Default Behavior:
concatenatejoins arrays along axis 0 by defaultappendflattens arrays by default (axis=None)
- Performance:
concatenateis generally faster and more memory-efficientappendcreates a new array and copies data, which is slower for large arrays
- Flexibility:
concatenatecan join multiple arrays at onceappendonly works with two arrays at a time
- Dimensionality:
concatenatepreserves dimensions by defaultappendflattens arrays unless you specify an axis
Here’s a simple benchmark to demonstrate the performance difference:
import numpy as np
import time
# Create large arrays
arr1 = np.random.rand(10000, 100)
arr2 = np.random.rand(10000, 100)
# Time concatenate
start = time.time()
np.concatenate((arr1, arr2), axis=0)
concat_time = time.time() - start
# Time append
start = time.time()
np.append(arr1, arr2, axis=0)
append_time = time.time() - start
print(f"Concatenate time: {concat_time:.6f} seconds")
print(f"Append time: {append_time:.6f} seconds")
print(f"Append is {append_time/concat_time:.2f}x slower")When to Use Concatenate vs Append
Based on my experience, here are my recommendations:
Read NumPy Average Filter in Python
Use Concatenate When:
- You need to join multiple arrays at once
- Performance is important
- You’re working with large datasets
- You need precise control over the dimension of concatenation
- You want to preserve memory efficiency
import numpy as np
# Joining multiple arrays of election data
data2016 = np.array([61.9, 65.8]) # Voter turnout percentages by region
data2020 = np.array([66.2, 69.1])
data2024 = np.array([62.1, 64.5])
# Join multiple arrays with a single call
all_election_data = np.concatenate((data2016, data2020, data2024))
print(all_election_data)Use Append When:
- You’re mainly working with 1D arrays
- You want the default flattening behavior
- Code readability is more important than performance
- You’re doing quick prototyping or exploratory analysis
import numpy as np
# A simple dataset that grows over time
temperatures = np.array([75, 76, 78, 79])
# New data point comes in
new_temp = np.array([81])
# Quick and readable way to add the new point
temperatures = np.append(temperatures, new_temp)
print(temperatures)Alternative Methods for Combining Arrays
While we’re discussing array joining, here are two other useful NumPy functions I often use:
Check out ValueError: setting an array element with a sequence error in Python
Use vstack and hstack
These functions are more intuitive when you specifically want to stack arrays vertically or horizontally:
import numpy as np
# US state data
west_states = np.array([['California', 'Oregon'],
['Nevada', 'Washington']])
east_states = np.array([['New York', 'Florida'],
['Maine', 'Georgia']])
# Vertical stacking (like concatenate with axis=0)
vertical = np.vstack((west_states, east_states))
print("Vertical stack:")
print(vertical)
# Horizontal stacking (like concatenate with axis=1)
horizontal = np.hstack((west_states, east_states))
print("\nHorizontal stack:")
print(horizontal)Use column_stack and row_stack
For even more clarity when working with columns and rows:
import numpy as np
# GDP data (in trillions)
years = np.array([2020, 2021, 2022, 2023])
gdp = np.array([20.9, 22.9, 25.5, 27.1])
# Stack as columns
data = np.column_stack((years, gdp))
print("Column stack (creating a table):")
print(data)I’ve found these functions make code more readable when the stacking direction is important to the logic of your program.
Read NumPy Normalize 0 and 1 in Python
Handle Shape Mismatch Errors
One common issue I encounter when using both concatenate and append is shape-mismatch errors. Let’s look at how to handle them:
import numpy as np
# Arrays with incompatible shapes
arr1 = np.array([[1, 2], [3, 4]]) # 2x2
arr2 = np.array([[5, 6, 7], [8, 9, 10]]) # 2x3
# This will cause an error
try:
np.concatenate((arr1, arr2), axis=0)
except ValueError as e:
print(f"Error: {e}")
# Possible solution: pad the smaller array
def pad_to_match(arr, target_shape, fill_value=0):
"""Pad array to match target shape along axis 1"""
result = np.full((arr.shape[0], target_shape[1]), fill_value)
result[:, :arr.shape[1]] = arr
return result
# Pad arr1 to match width of arr2
arr1_padded = pad_to_match(arr1, arr2.shape)
print("Padded array:")
print(arr1_padded)
# Now we can concatenate along axis 0
result = np.concatenate((arr1_padded, arr2), axis=0)
print("\nConcatenated result:")
print(result)This pattern is particularly useful when working with real-world data that might have missing values or different numbers of features.
Using NumPy’s concatenate and append correctly can significantly impact both your code’s performance and readability. While append might seem more intuitive at first, I’ve found that concatenate is usually the better choice for serious data processing work due to its flexibility and performance advantages.
Remember that append creates a copy of the array each time, which can lead to memory issues with very large datasets. On the other hand, concatenate gives you more precise control over exactly how your arrays are joined.
I hope you found this guide helpful in understanding when to use each function in your Python data analysis projects.
Other articles you may also like:

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.