Reputation: 882
I have been reading a very old documentation of Numpy and found out a weird notation which eludes my understanding. The documentation says a[i:...]
is a shortcut for a[i,:,:,:]
.
The documentation being old is very vague and I would welcome any comments.
Thanks, Prerit
Upvotes: 1
Views: 2069
Reputation: 882
Three full stops ...
(and not …
(U+2026)), refers to the Ellipsis singleton object. It has no built-in special operations but is often used in slicing expressions.
No built-in classes utilise the Ellipsis object however NumPy uses ...
as a shortcut when slicing arrays, for example, where x
is a 4D array: x[i, ...]
is equivalant to x[i, :, :, :]
.
Upvotes: 5
Reputation:
arr[:,:,1]
is fancy indexing used by numpy that selects the first element of the last column in arr
. Fancy indexing can only be used in numpy arrays and not in python's traditional lists.
Also, like its pointed out in the comments, a[,:,:,]
is a syntax error.
It is helpful because you can select columns easily
Upvotes: 2