Why is array1[:][1] != array1[:,1] ?
For example:
array1 = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
array1[1] ## Output: array([4,5,6]) as expected
array1[:,1] ## Output: array([2, 5, 8]) as expected
array1[:][1] ## Output: array([4,5,6]) which isn't what I expected!
When using double bracket referencing, is the array1[:] component executed first returning the full 2D array? Therefore array1[:][1] == array1[1]?
NumPy will interpret
a[:]as a copy of the array instead of the set of ‘rows’. Basic slicing is only analogous to successive slicing until:entries appear. From the docs (section 1.4 – Indexes):There is an implied complication when
:entries get handled.