Home >Backend Development >Python Tutorial >Complete list of numpy functions
Numpy functions include np.array(), np.zeros(), np.ones(), np.empty(), np.arange(), np.linspace(), np.shape() , np.reshape(), np.resize(), np.concatenate(), np.split(), np.add(), np.subtract(), np.multiply(), etc.
The operating system for this tutorial: Windows 10 system, Python version 3.11.4, DELL G3 computer.
The numpy library provides many functions, covering array creation, array operations, mathematical operations, statistics, and array indexing. The following are some commonly used numpy functions:
1. Array creation and initialization functions:
np.array(): Create an array from a list or tuple.
np.zeros(): Create an array of all 0s.
np.ones(): Create an array of all ones.
np.empty(): Create an array without initialization value.
np.arange(): Create an arithmetic sequence array.
np.linspace(): Create an equally spaced array within the specified range.
2. Array operation function:
np.shape(): Returns the shape of the array.
np.reshape(): Change the shape of the array.
np.resize(): Change the size of the array.
np.concatenate(): Concatenate two or more arrays.
np.split(): Split an array into multiple subarrays.
3. Mathematical operation function:
np.add(): addition operation.
np.subtract(): subtraction operation.
np.multiply(): Multiplication operation.
np.divide(): Division operation.
np.power(): Power operation.
np.sqrt(): square root operation.
np.sin(): Sine function.
np.cos(): Cosine function.
np.exp(): Exponential function.
np.log(): Logarithmic function.
4. Statistical function:
np.mean(): Calculate the average.
np.median(): Calculate the median.
np.std(): Calculate the standard deviation.
np.var(): Calculate the variance.
np.max(): Find the maximum value in the array.
np.min(): Find the minimum value in the array.
5. Array index and slicing functions:
np.shape(): Returns the shape of the array.
np.reshape(): Change the shape of the array.
np.concatenate(): Concatenate two or more arrays.
These are just a small part of the numpy functions, there are many other functions and usages.
The above is the detailed content of Complete list of numpy functions. For more information, please follow other related articles on the PHP Chinese website!