'Python: Split numpy array by index

So I have a numpy array with lots of nested arrays inside. Each nested array contains lots of data e.g.

[[ 0.27048764 -0.29546663 -0.7458692  ... -4.9339285  -5.6773453
-6.092227  ]
[ 0.901569    0.810158    0.2176554  ... -4.799445   -5.484735
-6.0386753 ]
[ 0.95575994  0.80078584  0.21802391 ... -4.9746757  -5.654247
-5.901661  ]

What I want to do is get each array one by one through a loop method and add it to a new numpy array .I am able to get one at a time though indexing but not through a loop.

e.g. [ 0.27048764 -0.29546663 -0.7458692 ... -4.9339285 -5.6773453 -6.092227 ]



Solution 1:[1]

You could do:

num = []

for index in range(len(arr)):
    for i in arr[index]:
        num.append(i)

np.array(num)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1