Python:NumPy Built-in Functions
Published May 25, 2022
Contribute to Docs
NumPy has many built-in functions for mathematical operations and array manipulation. Selected ones are listed below.
Built-in Functions
- .amax()
- Returns the maximum of a given array or maximum along an axis.
- .amin()
- Returns the minimum of an array or minimum along an axis.
- .append()
- Appends values to the end of an array.
- .arange()
- Generates evenly spaced values within a given interval; commonly used to create numeric sequences in NumPy.
- .argmax()
- Returns the indices of the maximum values along a specified axis in an array
- .argmin()
- Finds the index of the minimum value in a NumPy array, either across the entire array or along a specified axis.
- .concatenate()
- Joins a sequence of arrays along an existing axis.
- .corrcoef()
- Computes the Pearson correlation coefficient of two specified arrays.
- .cumprod()
- Computes the cumulative product of elements in an array along a specified axis.
- .cumsum()
- Computes the cumulative sum of elements in an array along a specified axis.
- .det()
- Computes the determinant of a square matrix.
- .dot()
- Computes the dot product of two arrays.
- .histogram()
- Computes the histogram of an array, summarizing the distribution of its values.
- .inv()
- Inverts a given matrix and returns the inverted matrix.
- .linspace()
- Creates an array of evenly spaced numbers over a specified interval.
- .log()
- Returns an element-wise natural logarithm for an array.
- .max()
- Returns the maximum value of an array or maximum values along a specified axis.
- .mean()
- Calculates the arithmetic mean of elements in a NumPy array along the specified axis.
- .median()
- Returns the median of the elements in a given array.
- .min()
- Finds the minimum value in an array or along a specified axis of an array.
- .nonzero()
- Returns the indices of the non-zero values in a given array.
- .ones()
- Creates a new array of the given shape and type, filled with ones.
- .percentile()
- Computes the q-th percentile of data along a specified axis.
- .quantile()
- Computes the qth quantile of the input array along the specified axis.
- .repeat()
- Duplicates elements in an array along a given axis.
- .reshape()
- Changes the shape of a NumPy array without altering its data or total size.
- .resize()
- Resizes an array and returns a new array with the specified size.
- .sort()
- Returns a sorted copy of an array in ascending order.
- .split()
- Divides an array into separate sub-arrays along a specified axis.
- .std()
- Calculates the standard deviation of given data along a specified axis.
- .sum()
- Sums the elements of an array over a given axis.
- .svd()
- Performs the Singular Value Decomposition (SVD) on a matrix, breaking it down into singular vectors and singular values.
- .tile()
- Constructs a new array by repeating the input array’s elements a specified number of times.
- .trace()
- Calculates the sum of the elements along the main diagonal of an array.
- .transpose()
- Alters the dimensional arrangement of an ndarray by reversing or swapping its axes.
- .var()
- Computes the variance of the array elements.
- .where()
- Returns elements from arrays depending on a condition.
- .zeros()
- Creates a new array filled with zeros.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Python:NumPy on Codecademy
- Machine Learning Data Scientists solve problems at scale, make predictions, find patterns, and more! They use Python, SQL, and algorithms.
- Includes 27 Courses
- With Professional Certification
- Beginner Friendly.95 hours
- Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.
- With Certificate
- Beginner Friendly.24 hours