Thanks for your replies. Let me explain my problem a little bit more. I have the following data which i read from a file using numpy.loadtxt and then i sort it using np.lexsort:
x=f[:,0] # XColumn y=f[:,1] # YColumn z=f[:,2] # ZColumn val=f[:,3] # Val Column xcoord=np.sort(np.unique(f[:,0])) # XCoordinates ycoord=np.sort(np.unique(f[:,1])) # YCoordinates zcoord=np.sort(np.unique(f[:,2])) # ZCoordinates ind = np.lexsort((val,z,y,x)) val_sorted=np.array(val[ind]) I know that the val column has data sorted first by x, then by y, then by z which means that column x changes slowest and column z changes fastest. x,y,z, val 0,0,0,val1 0,0,1,val2 0,0,2,val3 .... 0,0,zn,valn ... xn,yn,zn,valfin I want to reshape val_sorted in to a 3d numpy array of (nx,ny,nz). which of the following is the correct way and why? #1 val_sorted_reshaped=val_sorted.reshape((xcoord.size,ycoord.size,zcoord.size)) #2 #val_sorted_reshaped=val_sorted.reshape((xcoord.size,ycoord.size,zcoord.size)).transpose() #3 #val_sorted_reshaped=val_sorted.reshape((zcoord.size,ycoord.size,xcoord.size)) #4 #val_sorted_reshaped=val_sorted.reshape((zcoord.size,ycoord.size,xcoord.size)).transpose() Thanks, -- https://mail.python.org/mailman/listinfo/python-list