I'm trying to make a 3D-array where each element references the current row, column and item. So if I have x=[0,1]
, y=[0,1,2]
and item=['a','b']
, I wish the output to be
arr = [ [ [00a, 10a], [01a, 11a], [02a, 12a] ],
[ [00b, 10b], [01b, 11b], [02b, 12b] ]]
I know that this can be easily done with a triple loop as such
for i in range(len(x)):
for j in range(len(y)):
for it in range(len(item)):
arr[i,j,it] = str(i)+str(j)+it
but is there a more elegant way to do it, for example with some numpy command? Thanks!