Given numpy
arrays of different dimensions, I want to concatenate them. Apparently this is quite a common problem but the answers I found didn't seem to match my problem.
After trying several different approaches on a little example I still can't make it work. I've already looked into Concat two arrays of different dimensions numpy and How to unnest a nested list [duplicate]. I also tried appending and flattening it.
import numpy as np
a = np.arange(9)
a = a.reshape((3,3))
b = []
b.append(a[0,:])
b.append(a[1,1:2])
b.append(a[2,2])
b = np.asarray(b).flatten()
print(b) # [array([0, 1, 2]) array([4]) 8]
In summary I always get some error messages stating that the dimensions don't match or something similar.