Why is A[:,i] different from A[:][i]?

A = np.array([
    [1,2,3],
    [4,5,6],
    [7,8,9]
])
print(A[:,0])
print(A[:][0])

output:

array([1, 4, 7])
array([1, 2, 3])

Im confused by the second output, because it should select : (everything) from the first dimension, so all row vectors. And 0 from the second dimension, the entries of the row vectors, to extract the 0th column vector.



Read more here: https://stackoverflow.com/questions/64944087/why-is-a-i-different-from-ai

Content Attribution

This content was originally published by tonik at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: