Python: NumPy Concatenate Arrays Example

In order to concatenate two or more arrays in Python using NumPy, we can make use of the numpy.concatenate() function.

Let's take a look at a simple example.



Example:
import numpy as np

data_array_1 = np.array([10, 15, 30, 40, 45, 50])
data_array_2 = np.array([5, 20, 25, 35])

data_concatenated = np.concatenate((data_array_1, data_array_2))

print(data_concatenated)
Output:
[10 15 30 40 45 50  5 20 25 35]


Python NumPy Concatenate Arrays Example
Documentation:

- https://numpy.org/doc/stable/reference/generated/numpy.concatenate.html

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!