Numpy - dylanmoz/notes GitHub Wiki

Numpy

Global Methods

np.array(array_like): np.ndarray
np.arange([start, ], stop, [step, ]): np.ndarray - Evenly spaced values by step from start to stop
np.zeros(shape): np.ndarray
  • Methods with the same format: ones, empty.
linspace(start, stop, num=50): np.ndarray - Returns evenly spaced numbers from start to stop
eye(N): np.ndarray - Creates an identity matrix of size NxN
np.sqrt, np.exp, np.sin, np.log - All take an np.ndarray and perform the corresponding operation on all values

np.random Methods

np.random.rand(d0, d1, ...): np.ndarray - No args gives a single value, pass args gives a matrix with those dimensions
np.random.randn(d0, d1, ...): np.ndarray - Same as rand but samples over a standard normal distribution.
np.random.randint(low, [high, size]): np.ndarray - Random integers from low to high

np.ndarray Methods

reshape(d0, d1, ...): np.ndarray
copy(): np.ndarray Create a new reference to the matrix
max, min, argmax, argmin - Self explanatory, arg___ methods return the index at which the match exists

np.ndarray Properties

shape, dtype