Normally Transposing a vector or matrix is method to swapped the value with each other.
Like ,
suppose we have one matrix 2*2. When we perform trasposing that time column value swapped in raw and waw value swapped in column.
Problem/Example
You need to transposing a vector or matrix.
Solution
For the transposing we use T method
Transposing Matrix</4>
# Load library import numpy as np # Create matrix matrix = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) # Transpose matrix matrix.T
OUTPUT:
array([[1, 4, 7],
[2, 5, 8],
[3, 6, 9]])
Discussion :
Transposing is a common operation in linear algebra where the column and row indices of each element are swapped.
One nuanced point that is typically overlooked outside of a linear algebra class is that,
technically, a vector cannot be transposed because it is just a collection of values.
Transpose vector
import numpy as np np.array([1, 2, 3, 4, 5, 6]).T
OUTPUT:
array([1, 2, 3, 4, 5, 6])
However, it is common to refer to transposing a vector as converting a row vector to
a column vector (notice the second pair of brackets) or vice versa:
Transpose vector with array
import numpy as np
np.array([[1, 2, 3, 4, 5, 6]]).T
[/code
OUTPUT:
array([[1],
[2],
[3],
[4],
[5],
[6]])