Want to learn machine learning? Use my machine learning flashcards.

# Transpose A Vector Or Matrix

## Preliminaries

```
# Load library
import numpy as np
```

## Create Vector

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

## Create Matrix

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

## Transpose Vector

```
# Tranpose vector
vector.T
```

```
array([1, 2, 3, 4, 5, 6])
```

## Transpose Matrix

```
# Transpose matrix
matrix.T
```

```
array([[1, 4, 7],
[2, 5, 8],
[3, 6, 9]])
```

#### Find an error or bug?

Everything on this site is available on GitHub. Head to and submit a suggested change. You can also message me directly on Twitter.