
Concatenate NumPy arrays
NumPy arrays can be concatenated by concatenate()
.
import numpy
a = numpy.array([7, 8, 9])
b = numpy.array([4, 5, 6])
c = numpy.concatenate((a, b))
print(c) # [7 8 9 4 5 6]
Side note, Python lists can be concatenated by simply using +
.
a = [1, 2, 3]
b = [4, 5]
c = a + b
print(c) # [1, 2, 3, 4, 5]
Comments
Powered by Markdown