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.

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))

[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 Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail:

Copyright ยฉ Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap