How to Access Splitted Arrays in NumPy


In this example we will show how to access the splitted arrays in Python NumPy.

Source Code

import numpy as np

n = np.array([1, 2, 3, 4, 5, 6, 7, 8])

split_n = np.array_split(n, 4)

print(split_n[0])
print(split_n[1])
print(split_n[2])
print(split_n[3])

Output:

[1 2]
[3 4]
[5 6]
[7 8]
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments