I want to take a basic 3d array like this:
b = np.arange(1,101).reshape(4,5,5)
b
Then I want to take the first index, and work down like a stairs.
b1 = [b[0:,0,0],b[0:,1,1],b[0:,2,2],b[0:,3,3],b[0:,4,4]]
b1 = np.asarray(b1)
b1 = np.transpose(b1)
b1
The above code doesn't look right, I'd rather use a loop. This is what I have so far:
for i in range(0,5):
b2 = b[0:,i,i]
b2 = np.asarray(b2)
b2 = b2.reshape(4,1)
print(b2)
My issue with the above output is it puts each iteration into one vertical array, then moves onto the next. How do I make the above code output something similar to my second block of code?
Apologies for the poor formatting, new to stackoverflow and just starting to learn code/numpy.
Thanks!