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
-

Facing issues? Have Questions? Post them here! I am happy to answer!


Author: Rakesh
Author Info:

Rakesh is a seasoned developer with over 10 years of experience in web and app development, and a deep knowledge of operating systems. Author of insightful How-To articles for Code2care.

Follow him on: X

Copyright © Code2care 2023 | Privacy Policy | About Us | Contact Us | Sitemap