NumPy Join & Split

Concatenate and split arrays.

✍️ 3 exercises + code challenge in this lesson
  • np.concatenate((a, b)) joins arrays.
  • np.vstack() stacks vertically, np.hstack() horizontally.
  • np.array_split(arr, n) splits into n parts.

Key Takeaways: NumPy Join & Split

Mastering NumPy Join & Split helps you write clean and reliable NumPy code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

NumPy Join & Split Code Example

NumPy
import numpy as np

a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
print(np.concatenate((a, b)))
print(np.vstack((a, b)))
print(np.array_split(np.arange(6), 3))
Output
[1 2 3 4 5 6]
[[1 2 3]
 [4 5 6]]
[array([0, 1]), array([2, 3]), array([4, 5])]
Free sign-in required · Google login available

NumPy Join & Split Practice Exercises

Check what you learned in “NumPy Join & Split”.

/ 3 solved
Fill in the blank

Join two arrays end to end.

np.((a, b))
✓ Correct! Not quite. Try again.
Multiple choice

Which function stacks arrays vertically (as rows)?

✓ Correct! Not quite. Try again.
Code challenge

Join a and b and print the result as a list.

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services