I am trying to find a solution for flattening the following lists of numpy arrays:
a = np.arange(9).reshape(3,3)
b = np.arange(25).reshape(5,5)
c = np.arange(4).reshape(2,2)
myarrs = [a,b,c]
d = np.arange(5*5*5).reshape(5,5,5)
myarrs2 = [a,b,c,d]
For my myarrs
I am using at the moment:
res = np.hstack([np.hstack(i) for i in myarrs])
But I was wondering if there are any other built-in methods for performing this task in particular in case of arrays with different shapes. I saw the other questions: Flattening a list of NumPy arrays? but they usually refer to arrays with the same shape.