Expanding the number of dimensions of a numpy array

less than 1 minute read

In order to expand the number of dimensions of a numpy array, there are several options: np.expand_dims(x, axis=1) or x[:, np.newaxis] or x[:, None]. Refer this doc page.