Implement the transpose of a matrix, where each element at position (i, j) is swapped to (j, i).
Transpose Operation:
(AT)ji=AijAn n×m matrix becomes an m×n matrix.
A: 2D NumPy array, shape (N, M) - input matrixInput: A = [[1, 2, 3], [4, 5, 6]]
Output: [[1, 4], [2, 5], [3, 6]]
Input: A = [[1, 2], [3, 4]]
Output: [[1, 3], [2, 4]]
Input: A = [[1, 2, 3, 4]]
Output: [[1], [2], [3], [4]]
Create a new array with shape (m, n) using np.zeros(), then fill it with a nested loop.
.T or np.transpose()Sign in to take notes on this problem
Accepts: array
Implement the transpose of a matrix, where each element at position (i, j) is swapped to (j, i).
Transpose Operation:
(AT)ji=AijAn n×m matrix becomes an m×n matrix.
A: 2D NumPy array, shape (N, M) - input matrixInput: A = [[1, 2, 3], [4, 5, 6]]
Output: [[1, 4], [2, 5], [3, 6]]
Input: A = [[1, 2], [3, 4]]
Output: [[1, 3], [2, 4]]
Input: A = [[1, 2, 3, 4]]
Output: [[1], [2], [3], [4]]
Create a new array with shape (m, n) using np.zeros(), then fill it with a nested loop.
.T or np.transpose()Sign in to take notes on this problem
Accepts: array