Title: Transpose A Vector Or Matrix
Slug: transpose_a_vector_or_matrix
Summary: How to transpose a vector or matrix in Python.
Date: 2017-09-02 12:00
Category: Machine Learning
Tags: Vectors Matrices Arrays
Authors: Chris Albon
In [13]:
# Load library
import numpy as np
In [14]:
# Create vector
vector = np.array([1, 2, 3, 4, 5, 6])
In [15]:
# Create matrix
matrix = np.array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
In [16]:
# Tranpose vector
vector.T
Out[16]:
In [17]:
# Transpose matrix
matrix.T
Out[17]: