Skip to content

Instantly share code, notes, and snippets.

@drmingle
Last active May 8, 2018 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drmingle/37a8a2902d7917fe165eacba44254e0b to your computer and use it in GitHub Desktop.
Save drmingle/37a8a2902d7917fe165eacba44254e0b to your computer and use it in GitHub Desktop.
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