21 August 2020
Code
# Import library
import numpy as np
# Create an array
x = np.array([[1,2,3],
[10,20,30],
[100,200,300]])
# Transpose
y = x.T
# Output
print('Original array:\n', x, '\n')
print('Transposed array:\n', y)
Original array:
[[ 1 2 3]
[ 10 20 30]
[100 200 300]]
Transposed array:
[[ 1 10 100]
[ 2 20 200]
[ 3 30 300]]
Any errors in code above?
Please send a message.