Title: Describe An Array
Slug: describe_a_matrix
Summary: How to describe an array.
Date: 2017-09-03 12:00
Category: Machine Learning
Tags: Vectors Matrices Arrays
Authors: Chris Albon

Preliminaries


In [1]:
# Load library
import numpy as np

Create Matrix


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

View Shape


In [3]:
# View number of rows and columns
matrix.shape


Out[3]:
(3, 4)

View Total Elements


In [4]:
# View number of elements (rows * columns)
matrix.size


Out[4]:
12

View Number Of Dimensions


In [5]:
# View number of dimensions
matrix.ndim


Out[5]:
2