How come if
c = np.arange(100).reshape([10,10])
then
c[0:6,2:4]
can successfully take a rectangular subset of the data, but this can't?
c[np.arange(6),np.arange(2,4)]
I have the following code, but I can't get the subset of data I need for it to work, please can you help me fix this? Thanks
# Box length in z-direction
z_length = features['Radial_pktrD'].values * 2
# Box width in x-direction
x_width = features['Radial_Width_50'].values
# Create array of index numbers for z and x arrays
zindex = np.arange(0,len(z),1)
xindex = np.arange(0,len(x),1)
# Box1 - bottom left (peak)
zind = zindex[(z < radial_centre_z) & (z > radial_centre_z-z_length)]
xind = xindex[(x < radial_centre_x) & (x > radial_centre_x - x_width)]
x_peak1,z_peak1 = np.where(radial[xind,zind]==np.max(radial[xind,zind]))
I have spent a long time searching for the answer to this question and so far I have not found anything that corresponds to using Numpy arrays for index' and how to do it, therefore I don't believe this question is a duplicate of this question. I am not asking about advanced selection but rather simple selection using Numpy arrays.
The error I get is in the line
x_peak1,z_peak1 = np.where(radial[xind,zind]==np.max(radial[xind,zind]))
The error message is
IndexError: shape mismatch: indexing arrays could not be broadcast together with shapes (19,) (31,)
Which I think essentially means you cannot use Numpy arrays in this way