Show Menu
Cheatography

Python-Numpy Cheat Sheet Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Basics

ndarra­y.ndim
number of axes of an array
ndarra­y.shape
dimensions of an array
ndarra­y.size
number of elements of an array
ndarra­y.dtype
type of elements in an array
ndarra­y.i­temsize
elements size of an array

Array Creation

array(­[1,­2,3,4])
array(­[[1­,2,­3,4], [5,6,7­,8]])
zeros(­[1,2])
ones([­1,2,3])
empty(­[2,3])
zeros_­like(A)
ones_l­ike(A)
empty_­like(A)
arange­(1,­10,5)
linspa­ce(­1,10,5)
random.ra­nd(3,2)
random.ra­ndn­(3,2)
fromfu­nct­ion­(...)
fromfi­le(...)

Basic Operations

A * B
dot(A,B)
A *=b
A +=b
A.sum()
A.min()
A.sum(­axis=0)
A.min(­axis=0)
A.cums­um(­axis=0)

Universal Functions

sin,co­s,e­xp,­log­,sqrt