python - numpy 3 dimension array middle indexing bug -


i seems found bug when i'm using python 2.7 numpy module:

import numpy np x=np.arange(3*4*5).reshape(3,4,5) x 

here got full 'x' array follows:

array([[[ 0,  1,  2,  3,  4],         [ 5,  6,  7,  8,  9],         [10, 11, 12, 13, 14],         [15, 16, 17, 18, 19]],         [[20, 21, 22, 23, 24],         [25, 26, 27, 28, 29],         [30, 31, 32, 33, 34],         [35, 36, 37, 38, 39]],         [[40, 41, 42, 43, 44],         [45, 46, 47, 48, 49],         [50, 51, 52, 53, 54],         [55, 56, 57, 58, 59]]]) 

then try indexing single row values in sheet [1]:

x[1][0][:] 

result:

array([20, 21, 22, 23, 24]) 

but wrong while try indexing single column in sheet [1]:

x[1][:][0] 

result still same previous:

array([20, 21, 22, 23, 24]) 

should array([20, 25, 30, 35])??

it seems wrong while indexing middle index range?

no, it's not bug.

when use [:] using slicing notation , takes list:

l = ["a", "b", "c"] l[:] #output: ["a", "b", "c"] 

and in case:

x[1][:] #output: array([[20, 21, 22, 23, 24],        [25, 26, 27, 28, 29],        [30, 31, 32, 33, 34],        [35, 36, 37, 38, 39]]) 

what realy wish using numpy indexing notation:

x[1, : ,0] #output: array([20, 25, 30, 35]) 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -