Interchange two axes of an array.
Parameters: | a : array_like
axis1 : int
axis2 : int
|
---|---|
Returns: | a_swapped : ndarray
|
Examples
>>> x = np.array([[1,2,3]])
>>> np.swapaxes(x,0,1)
array([[1],
[2],
[3]])
>>> x = np.array([[[0,1],[2,3]],[[4,5],[6,7]]])
>>> x
array([[[0, 1],
[2, 3]],
<BLANKLINE>
[[4, 5],
[6, 7]]])
>>> np.swapaxes(x,0,2)
array([[[0, 4],
[2, 6]],
<BLANKLINE>
[[1, 5],
[3, 7]]])