In NumPy, how can you efficiently make a 1-D object into a 2-D object where the singleton dimension is inferred from the current object (i.e. a list should go to either a 1x
What about expand_dims?
np.expand_dims(np.array([1,2,3,4]), 0)
has shape (1,4) while
(1,4)
np.expand_dims(np.array([1,2,3,4]), 1)
has shape (4,1).
(4,1)