I want to slice a NumPy nxn array. I want to extract an arbitrary selection of m rows and columns of that array (i.e. without any pattern in the numbers of rows/col
I'm not sure how efficient this is but you can use range() to slice in both axis
x=np.arange(16).reshape((4,4)) x[range(1,3), :][:,range(1,3)]