1. Ellipsis Object (…):

It is an object in Python that can be used in matrix slicing in Numpy package and also for generic list slicing as well. The main aim of this object is to make multidimensional array handling easier. The multiple indices in the Numpy array can be replaced with … (Ellipsis object).

Also, it can be used in place of pass command in Python to implement “no operation” when defining empty functions.

>>> import numpy as np
>>> a = np.array([[[i + 2*j + 8*k for i in range(3)] for j in range(3)] for k in range(3)])
>>> arr = np.array(a)
>>> arr
array([[[ 0,  1,  2], [ 2,  3,  4], [ 4,  5,  6]],
[[ 8,  9, 10], [10, 11, 12], [12, 13, 14]],
[[16, 17, 18], [18, 19, 20], [20, 21, 22]]])
>>> arr[1,...]
array([[ 8,  9, 10], [10, 11, 12], [12, 13, 14]])
>>> arr[...,1]
array([[ 1,  3,  5], [ 9, 11, 13], [17, 19, 21]])

#machine-learning #data #data-science #data-scientist #data-engineering

ML Programming Hacks that every Data Engineer should know
1.15 GEEK