Title: Reshape An Array
Slug: reshape_an_array
Summary: How to reshape a NumPy array.
Date: 2017-09-04 12:00
Category: Machine Learning
Tags: Vectors Matrices Arrays
Authors: Chris Albon
In [1]:
# Load library
import numpy as np
In [2]:
# Create a 4x3 matrix
matrix = np.array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[10, 11, 12]])
In [3]:
# Reshape matrix into 2x6 matrix
matrix.reshape(2, 6)
Out[3]: