Concatenating two one-dimensional NumPy arrays
Asked 07 September, 2021
Viewed 1.9K times
  • 58
Votes

I have two simple one-dimensional arrays in NumPy. I should be able to concatenate them using numpy.concatenate. But I get this error for the code below:


TypeError: only length-1 arrays can be converted to Python scalars

Code

import numpy
a = numpy.array([1, 2, 3])
b = numpy.array([5, 6])
numpy.concatenate(a, b)

Why?

6 Answer