Numpy Array
Numpy Array
NumPy Methods
Method Description
np.array() Create a new array from a list or tuple.
np.arange() Return evenly spaced values within a given interval.
np.zeros() Return a new array of given shape and type, filled with zeros.
np.ones() Return a new array of given shape and type, filled with ones.
np.empty() Return a new array of given shape and type, without initializing en-
tries.
np.reshape() Gives a new shape to an array without changing its data.
np.flip() Reverse the order of elements in an array along the given axis.
np.concatenate() Join a sequence of arrays along an existing axis.
np.split() Split an array into multiple sub-arrays.
np.append() Append values to the end of an array.
np.delete() Return a new array with sub-arrays along an axis deleted.
np.unique() Find the unique elements of an array.
np.dot() Dot product of two arrays. For 2-D arrays it is equivalent to matrix
multiplication.
np.sum() Sum of array elements over a given axis.
np.mean() Compute the arithmetic mean along the specified axis.
np.median() Compute the median along the specified axis.
np.std() Compute the standard deviation along the specified axis.
np.max() Return the maximum along a given axis.
np.min() Return the minimum along a given axis.
np.sort() Return a sorted copy of an array.
Method Description
np.linalg.inv() Compute the multiplicative inverse of a matrix.
np.linalg.det() Compute the determinant of an array.
np.linalg.eig() Compute the eigenvalues and right eigenvectors of a square array.
np.cross() Return the cross product of two (arrays of) vectors.
np.histogram() Compute the histogram of a set of data.
np.fft.fft() Compute the one-dimensional discrete Fourier Transform.
np.fft.ifft() Compute the one-dimensional inverse discrete Fourier Transform.
np.sin() Trigonometric sine, element-wise.
np.cos() Trigonometric cosine, element-wise.
np.tan() Trigonometric tangent, element-wise.
np.exp() Calculate the exponential of all elements in the input array.
np.log() Natural logarithm, element-wise.
np.sqrt() Return the non-negative square-root of an array, element-wise.
1
Method Description
np.power() First array elements raised to powers from second array, element-wise.
np.vstack() Stack arrays in sequence vertically (row wise).
np.hstack() Stack arrays in sequence horizontally (column wise).
np.ravel() Return a contiguous flattened array.
np.transpose() Permute the dimensions of an array.
np.linalg.solve() Solve a linear matrix equation, or system of linear scalar equations.
np.linalg.svd() Singular Value Decomposition.
Function Description
scipy.misc.derivative() Compute derivatives using finite difference methods.
numpy.gradient() Calculate the gradient of an N-dimensional array for approximate par-
tial derivatives.
scipy.integrate.quad() General purpose single integration.
scipy.integrate.dblquad() Double integration.
scipy.integrate.tplquad() Triple integration.
scipy.integrate.nquad() N-dimensional integration.
scipy.integrate.simps() Integration using Simpson’s rule.
scipy.integrate.trapz() Integration using the trapezoidal rule.
scipy.integrate.cumtrapz() Cumulative integration using the trapezoidal rule.
scipy.integrate.romb() Integration using Romberg Integration.
scipy.integrate.solvei vp() Solve an initial value problem for a system of ODEs.
scipy.integrate.odeint() Solve ODEs (older API, but useful for certain problems).
scipy.optimize.minimize() Minimization of scalar function of one or more variables.
scipy.optimize.root() Find a root of a function.
scipy.optimize.curvef it() Fit a function to data using non-linear least squares.
numpy.fft.fft() Compute the one-dimensional discrete Fourier Transform.
scipy.fft.fft() Compute the one-dimensional discrete Fourier Transform with more
options and flexibility.
scipy.special (Various Functions) Special functions module for calculus-related tasks.