Table of contents

Starting with NumPy Array,

top

Creating an array

Creating an array using arange()

Create an array of all zeros

Create an array of all ones

Create a constant array

Create an indentity matrix

Create a random matrix (uniform distribution on (0,1))

type() and dtype functions

Shape of an array and getting specific elements

Manipulating Shape of NumPy Array

top

Reshaping an array

flatten/transpose/ resize an array

Stacking of Numpy arrays

top

multiplying by a number

Two arrays are stacked horizontally along the $x$ axis..

Horizontal stacking using concatenate() function

Vertical stacking

Or we can proceed as following

Stack by columns

Create column stack

Create 1-D array

Create column stack

Partitioning Numpy Array

top

Perform horizontal splitting

Vertical split

Split with axis=0

Changing Datatype of NumPy Arrays

top

Change datatype of array

Check new data type of array

Convert NumPy array to Python List

Slicing NumPy Array

top

Coefficients from the 3rd to the 6th

Coefficients from the 3rd

The last 3 coefficients

Boolean and Fancy Indexing

top

Boolean Indexing

Selecting 2nd and 3rd row

Selecting 3nd and 4th row

Create row and column indices

Broadcasting arrays

top

Sum two matrices

Multiply two matrices: $A=(a_{ij})$ and $B=(b_{ij})$, $AB=(a_{ij}b_{ij})$ ($A$ and $B$ are with same dimensions)

Add a scaler value

Multiply with a scalar value

Multiply matrices

$A=(a_{ij})$ is an $n\times p$ matrix and $B=(b_{ij})$ is an $p\times q$ matrix. The $C=(c_{ij})$, where $c_{ij}=\displaystyle\sum_{k=1}^p a_{ik}b_{kj}$, is an $n\times q$ matrix.