I was trying to read the numpy indexing docs, but was still unclear on why this is the case. Is the behavior mentioned in the title just a convention, or is there some underlying design decision I'm missing?
Thanks.
I was trying to read the numpy indexing docs, but was still unclear on why this is the case. Is the behavior mentioned in the title just a convention, or is there some underlying design decision I'm missing?
Thanks.
It is because you are selecting/slicing a single row and you getting all elements from that row with a shape of (3,). The second method is looking for all rows even though it is only going to return one row, it is going to shape the output as rows hence (1,3) shape.
See this post for images. https://stackoverflow.com/a/55581845/6361531
v[:,:]has two dimensions with sizes (1, 3), whilev[0,:]is just the first element in the first dimension of v, which has one dimension size 3v[0,:]is an example of integerbasicindexing. That's the previous docs section to the one you linked. "An integer, i, returns the same values as i:i+1 except the dimensionality of the returned object is reduced by 1."