I have to make a list of arrays grouped out from the first column number. This is using numpy. I have following array; x. The first column shows how the arrays should be organized with the numbers 0,1,3 and 4.
x = np.array([[0,0,0,0,3],
[1,0,0,2,3],
[4,0,0,0,0],
[3,0,0,0,2],
[0,0,0,0,3],
[1,0,0,2,3]])
I found out how to sort the array:
data = x[np.argsort(x[:, 0])]
print(data)
[[0 0 0 0 3]
[0 0 0 0 3]
[1 0 0 2 3]
[1 0 0 2 3]
[3 0 0 0 2]
[4 0 0 0 0]]
But the output has to be a list with elements of arrays like this:
list_of_arrays = np.array([[[0,0,0,3],
[0,0,0,3]],
[[0,0,2,3],[0,0,2,3]],
[[0,0,0,2]],
[[0,0,0,0]]])
So the first column works as a marker for how the arrays should look like in the list. I'm pretty new to python and coding in general, so any help is much appreciated.