Numpy
Arrays

Using reversed()
Using numpy.flipud()
Shape and Reshape
Shape
The shape tool gives a tuple of array dimensions and can be used to change the dimensions of an array.
(a). Using shape to get array dimensions
(b). Using shape to change array dimensions
Reshape
The reshape tool gives a new shape to an array without changing its data. It creates a new array and does not modify the original array itself.
Task

Transpose and Flatten
Transpose
We can generate the transposition of an array using the tool numpy.transpose.
It will not affect the original array, but it will create a new array.
Flatten
The tool flatten creates a copy of the input array flattened to one dimension.
Task

Concatenate
Two or more arrays can be concatenated together using the concatenate function with a tuple of the arrays to be joined:
If an array has more than one dimension, it is possible to specify the axis along which multiple arrays are concatenated. By default, it is along the first dimension.
Task

Zeroes and Ones
The zeros tool returns a new array with a given shape and type filled with 's.
The ones tool returns a new array with a given shape and type filled with 's.
Task

Eye and Identity
The identity tool returns an identity array. An identity array is a square matrix with all the main diagonal elements as and the rest as . The default type of elements is float.
The eye tool returns a 2-D array with 's as the diagonal and 's elsewhere. The diagonal can be main, upper or lower depending on the optional parameter . A positive is for the upper diagonal, a negative is for the lower, and a (default) is for the main diagonal.
Task

Array Mathematics
Basic mathematical functions operate element-wise on arrays. They are available both as operator overloads and as functions in the NumPy module.

Floor, Ceil and Rint
The tool floor returns the floor of the input element-wise. The floor of is the largest integer where .
The tool ceil returns the ceiling of the input element-wise. The ceiling of is the smallest integer where .
The rint tool rounds to the nearest integer of input element-wise.
Task

Sum and Prod
The sum tool returns the sum of array elements over a given axis.
By default, the axis value is None. Therefore, it performs a sum over all the dimensions of the input array.
The prod tool returns the product of array elements over a given axis.
By default, the axis value is None. Therefore, it performs the product over all the dimensions of the input array.
Task

Min and Max
The tool min returns the minimum value along a given axis.
By default, the axis value is None. Therefore, it finds the minimum over all the dimensions of the input array.
The tool max returns the maximum value along a given axis.
By default, the axis value is None. Therefore, it finds the maximum over all the dimensions of the input array.
Task

Mean, Var, and Std
The mean tool computes the arithmetic mean along the specified axis.
By default, the axis is None. Therefore, it computes the mean of the flattened array.
The var tool computes the arithmetic variance along the specified axis.
By default, the axis is None. Therefore, it computes the variance of the flattened array.
The std tool computes the arithmetic standard deviation along the specified axis.
By default, the axis is None. Therefore, it computes the standard deviation of the flattened array.
Task

Dot and Cross
The dot tool returns the dot product of two arrays.
The cross tool returns the cross product of two arrays.
Task

Inner and Outer
The inner tool returns the inner product of two arrays.
The outer tool returns the outer product of two arrays.
Task

Polynomials
The poly tool returns the coefficients of a polynomial with the given sequence of roots.
The roots tool returns the roots of a polynomial with the given coefficients.
The polyint tool returns an antiderivative (indefinite integral) of a polynomial.
The polyder tool returns the derivative of the specified order of a polynomial.
The polyval tool evaluates the polynomial at specific value.
The polyfit tool fits a polynomial of a specified order to a set of data using a least-squares approach.
The functions polyadd, polysub, polymul, and polydiv also handle proper addition, subtraction, multiplication, and division of polynomial coefficients, respectively.
Task

Linear Algebra
The NumPy module also comes with a number of built-in routines for linear algebra calculations. These can be found in the sub-module linalg.
The linalg.det tool computes the determinant of an array.
The linalg.eig computes the eigenvalues and right eigenvectors of a square array.
The linalg.inv tool computes the (multiplicative) inverse of a matrix.
Other routines can be found here
Task

Last updated
Was this helpful?