python - numpy array traversal Error: IndexError: index 1 is out of bounds for axis 0 with size 1 -


numpy shape (5,1) following elements:

[[1]  [2]  [3]  [4]  [5]] 

how go traversing through , printing each element? follows:

1 2 3 4 5 

attempt

for row in range(n):     col in range(d):         print(input_array[row][col]) 

error

error: indexerror: index 1 out of bounds axis 0 size 1 

your n, d values must wrong. either do

n, d = input_array.shape 

and continue code, or directly

for row in input_array:     token in row:         print(token) 

Comments

Popular posts from this blog

c++ - CPP, 'X' button listener -

.net - Bulk insert via Dapper is slower than inserting rows one-by-one -

shared memory - gstreamer shmsrc and shmsink with h264 data -