Lesson 10 of 10 · 2 min
Quick Reference
import numpy as np np.array([1,2,3]) # create array from list np.arange(start,stop,step) # range array np.zeros((m,n)) # m×n zeros np.ones((m,n)) # m×n ones np.random.rand(n) # n random floats [0,1) np.random.randint(a,b,size=n) # n random ints arr.reshape(m,n) # reshape to m×n arr.flatten() # 1D arr.shape # (rows, cols) arr.dtype # data type np.sum(arr) # sum all elements np.mean(arr) # mean np.std(arr) # standard deviation np.dot(A, B) # matrix multiplication arr[arr > 5] # boolean filter
