Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
title author date
Transpose A Vector Or A Matrix
Damian Mingle
05/08/2018

Preliminaries

import numpy as np

Create Vector

# Create vector
vector = np.array([9,8,7,6,5,4,3,2,1])

Create Matrix

# Create matrix
matrix = np.array([[9, 8, 7],
                   [6, 5, 4],
                   [3, 2, 1]])

Transpose Vector

# Tranpose vector
vector.T
array([9, 8, 7, 6, 5, 4, 3, 2, 1])

Transpose Matrix

# Transpose matrix
matrix.T
array([[9, 6, 3],
       [8, 5, 2],
       [7, 4, 1]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.