Skip to content
Advertisement

Python Numpy; difference between colon and ellipsis indexing

I have been experimenting with Numpy array indexing using both colon and ellipsis. However, I cannot understand the results that I am getting.

Below is the example code:

JavaScript

Advertisement

Answer

The original is (2,2)

With :, it becomes (2,1,2). The new axis added after the first dimension.

With … the shape is (2,2,1), the new shape is added last.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement