Use:

np.concatenate([a, b])

The arrays you want to concatenate need to be passed in as a sequence, not as separate arguments.

From the NumPy documentation:

numpy.concatenate((a1, a2, ...), axis=0)

Join a sequence of arrays together.

It was trying to interpret your b as the axis parameter, which is why it complained it couldn't convert it into a scalar.

Answer from Winston Ewert on Stack Overflow
🌐
W3Schools
w3schools.com › python › numpy › numpy_array_join.asp
NumPy Joining Array
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. ... import numpy as np arr1 = np.array([1, 2, 3]) arr2 = np.array([4, 5, 6]) arr = ...
🌐
DataCamp
datacamp.com › doc › numpy › concatenate
NumPy concatenate()
The `concatenate()` function is used when you need to combine arrays of the same shape along a particular axis. It requires the arrays to be of the same shape except for the dimension specified by the axis. ... Here, the `concatenate()` function takes a sequence of arrays, `array1`, `array2`, ...
🌐
Codecademy
codecademy.com › docs › python:numpy › built-in functions › .concatenate()
Python:NumPy | Built-in Functions | .concatenate() | Codecademy
May 1, 2025 - This example demonstrates how to concatenate two 1D arrays along the default axis (axis=0): ... The .concatenate() function combines the two arrays end-to-end, creating a new array that contains all elements from both input arrays in sequence.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › joining-numpy-array
Joining NumPy Array - GeeksforGeeks
July 15, 2025 - numpy.stack() joins arrays along a new axis, increasing the dimensionality. It is useful when you want to combine arrays but keep them separated along a new dimension.
🌐
Codecademy
codecademy.com › article › numpy-concatenate
How to Use np.concatenate() in NumPy (With Examples and Comparisons) | Codecademy
This function returns a new array that contains the concatenation of the given arrays. Next, let’s see an example that uses the np.concatenate() function to join two NumPy arrays vertically (axis=0):
🌐
Nanyang Technological University
libguides.ntu.edu.sg › python › combiningarrays
NP.7 Combining 2 arrays - Python for Basic Data Analysis - LibGuides at Nanyang Technological University
August 26, 2026 - In NumPy, you can join 2 or more arrays together using np.concatenate. To do so, you will need to ensure that if you are adding a row, the rows of both arrays must be the same.
🌐
Medium
giulio-laurenti.medium.com › joining-numpy-arrays-806fe428b90e
Joining Numpy Arrays. Joining arrays means taking elements… | by Giulio Laurenti, PhD | Medium
July 7, 2025 - # Create two 2D arrays a = np.array([[23, 45, 67], [38, 18, 79]]) a array([[23, 45, 67], [38, 18, 79]]) b =…
🌐
EDUCBA
educba.com › home › software development › software development tutorials › numpy tutorial › numpy concatenate arrays
NumPy concatenate arrays | Working of NumPy concatenate arrays
April 15, 2023 - Whenever there is a need to join two or more arrays which are of the same shape, we make use of a function in NumPy called concatenate function where concatenation means joining and concatenate function in NumPy takes two parameters arrayname1 ...
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Vultr Docs
docs.vultr.com › python › third party › numpy › concatenate()
Python Numpy concatenate() - Join Arrays Together
November 7, 2024 - Define two or more arrays to concatenate. Apply the concatenate() function. ... import numpy as np array1 = np.array([1, 2, 3]) array2 = np.array([4, 5, 6]) result = np.concatenate((array1, array2)) print(result)
🌐
Career Karma
careerkarma.com › blog › python › numpy concatenate: a guide
NumPy Concatenate: A Guide | Career Karma
December 1, 2023 - You can concatenate two or more 1d arrays using the vstack and hstack methods. concatenate() is more efficient than these methods. concatenate() also supports concatenating 2d, 3d, and higher dimension arrays.
🌐
Programiz
programiz.com › python-programming › numpy › methods › concatenate
NumPy concatenate()
If we pass None as the axis argument, concatenate() flattens the arrays and concatenates them. import numpy as np array1 = np.array([[0, 1], [2, 3]]) array2 = np.array([[10, 11], [12, 13]])
🌐
datagy
datagy.io › home › numpy › different ways to concatenate numpy arrays in python
Different Ways to Concatenate NumPy Arrays in Python • datagy
December 30, 2022 - In the next section, you’ll learn how to take on this task but join the arrays across the columns. In order to join NumPy arrays column-wise, we can also use the concatenate() function.
🌐
NumPy
numpy.org › doc › stable › reference › routines.array-manipulation.html
Array manipulation routines — NumPy v2.5 Manual
copyto(dst, src[, casting, where]) · Copies values from one array to another, broadcasting as necessary
🌐
iO Flood
ioflood.com › blog › numpy-concatenate
Numpy Concatenate: Mastering Array Joining in Python
January 30, 2024 - With numpy concatenate, you can easily join arrays of data, making it a crucial tool for data preprocessing in Python. In machine learning, you frequently need to combine features from different sources into a single feature vector.