1>>> a = np.array([[1, 2], [3, 4]])
2>>> a
3array([[1, 2],
4 [3, 4]])
5>>> a.transpose()
6array([[1, 3],
7 [2, 4]])
8>>> a.transpose((1, 0))
9array([[1, 3],
10 [2, 4]])
11>>> a.transpose(1, 0)
12array([[1, 3],
13 [2, 4]])
14
1matrix = ((0, 1), (3, 4), (6, 7))
2#Transpose matrix from 3x2 to 2x3
3
4matrix_transpose = tuple(zip(*data))
5print(data_transpose)
6
7#Output
8((0, 3, 6), (1, 4, 7), (2, 5, 8))
9
1
2import numpy as np
3
4arr1 = np.array([[1, 2, 3], [4, 5, 6]])
5
6print(f'Original Array:\n{arr1}')
7
8arr1_transpose = arr1.transpose()
9
10print(f'Transposed Array:\n{arr1_transpose}')
11
1import numpy as np
2
3A = [1, 2, 3, 4]
4np.array(A).T # .T is used to transpose matrix