Difference between array[i][:] and array[i,:]

Viewed 7007

I'm new to python, so I'm used to use array[i][j] instead of array[i,j]. Today a script I created following a tutorial was not working until I found out that I was using

numpy.dot(P[0][:], Q[:][0])

instead of

numpy.dot(P[0,:], Q[:,0])

For some reason the second one works, while the first one gives me a shape error. The matrixes dimensions are MxK and KxN.

I tried to print both P[0][:] and P[0,:], run id(), type() and P[0][:].shape, but couldn't find a reason to it. Why are these things different?

I'm running it on Jupyter Notebook 4.3.0 and Python 2.7.13.

2 Answers
Related