Heli wrote: > I sort a file with 4 columns (x,y,z, somevalue) and I sort it using > numpy.lexsort. > > ind=np.lexsort((val,z,y,x)) > > myval=val[ind] > > myval is a 1d numpy array sorted by x,then y, then z and finally val. > > how can I reshape correctly myval so that I get a 3d numpy array > maintaining the xyz ordering of the data? > > > my val looks like the following: > > x,y,z, val > 0,0,0,val1 > 0,0,1,val2 > 0,0,2,val3 > ... > > Thanks a lot for your help,
I'm not sure I understand the question. Does shape = [max(t) + 1 for t in [x, y, z]] cube = myval.reshape(shape) give what you want? -- https://mail.python.org/mailman/listinfo/python-list