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

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -