Hi @Krishna_Hrithik
A 1D array has one axis, a 2D array has 2 axes, and an nD array has n axes. For instance, take a look at the following illustration:
The shape of the array reveals the number of elements along each axis.
arr = np.arange(24)
arr = np.reshape(arr, (3, 4, 2))
When we do the following:
transposed = np.transpose(arr, axes=(1, 2, 0))
The first dimension of arr
becomes the third dimension of transposed
, the second dimension of arr
becomes the first dimension of transposed
, and the third dimension of arr
becomes the second dimension of transposed
. Hence, the shape of transposed is (4, 2, 3).
Best Regards,
Hiba | Developer Advocate
educative.io