NumPy Array Functions Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report NumPy array functions are a set of built-in operations provided by the NumPy library that allow users to perform various tasks on arrays. With NumPy array functions, you can create, reshape, slice, sort, perform mathematical operations, and much moreāall while taking advantage of the library's speed and efficiency.Table of ContentArray Creation FunctionsArray Manipulation FunctionsMathematical and Statistical FunctionsIndexing and Slicing FunctionsSorting and Searching FunctionsInput/Output FunctionsDifferent Methods in NumPy ArrayThis article explores some of the most important NumPy array functions with examples to help you harness their power.Array Creation Functions np.array(): Converts a Python list, tuple, or sequence into an array. Python import numpy as np arr = np.array([1, 2, 3]) print(arr) np.zeros(): Creates an array filled with zeros. Python import numpy as np zeros_array = np.zeros((2, 3)) print(zeros_array) np.ones(): Creates an array filled with ones. Python import numpy as np ones_array = np.ones((3, 2)) print(ones_array) np.arange(): Generates an array with values in a specified range. Python import numpy as np range_array = np.arange(0, 10, 2) print(range_array) np.linspace() : Generates an array of evenly spaced numbers over a specified range. Python import numpy as np linear_array = np.linspace(0, 1, 5) print(linear_array) np.random Functions: Generates arrays with random values. Python import numpy as np random_array = np.random.rand(2, 3) print(random_array) Array Manipulation Functionsnp.reshape(): Reshapes an array without changing its data. Python import numpy as np reshaped = np.reshape(np.arange(6), (2, 3)) print(reshaped) np.flatten(): Flattens a multi-dimensional array into one dimension. Python import numpy as np flattened = reshaped.flatten() print(flattened) np.transpose(): Transposes the dimensions of an array. Python import numpy as np transposed = reshaped.T print(transposed) np.concatenate(): Joins two or more arrays along an axis. Python import numpy as np a = np.array([1, 2]) b = np.array([3, 4]) concatenated = np.concatenate((a, b)) print(concatenated) Mathematical and Statistical Functionsnp.sum() : Computes the sum of array elements. Python import numpy as np array = np.array([1, 2, 3]) total = np.sum(array) print(total) np.mean(): Computes the mean of array elements. Python import numpy as np mean_value = np.mean(array) print(mean_value) np.max() and np.min(): Find the maximum and minimum values in an array. Python import numpy as np max_val = np.max(array) min_val = np.min(array) print(max_val) print(min_value) np.sqrt(): Computes the square root of each element in an array. Python import numpy as np sqrt_array = np.sqrt(array) print(sqrt_array) Indexing and Slicing FunctionsIndexing: Access specific elements Python import numpy as np array = np.array([1, 2, 3, 4]) element = array[2] print(element) Slicing: Access subsets of arrays Python import numpy as np subset = array[1:3] print(subset) Sorting and Searching Functionsnp.sort(): Sorts an array. Python import numpy as np sorted_array = np.sort(np.array([3, 1, 2])) print(sorted_array) np.argsort() : Returns the indices of the sorted elements. Python import numpy as np indices = np.argsort(np.array([3, 1, 2])) print(indices) np.where(): Returns the indices of elements that satisfy a condition. Python import numpy as np array = np.array([1, 2, 3, 4]) indices = np.where(array > 2) print(indices) Input/Output Functionsnp.save() and np.load(): Save and load arrays in binary format. Python import numpy as np np.save('array.npy', array) loaded_array = np.load('array.npy') print(loaded array) np.savetxt() and np.loadtxt() : Save and load arrays in text format. Python import numpy as np np.savetxt('array.txt', array) loaded_array = np.loadtxt('array.txt') print(loaded_array) Other Different Methods of NumPy Arrayall()diag()hypot()ones_like()any()diagflat()absolute()full_like()take()diag_indices()ceil()sin()put()asmatrix()floor()cos()apply_along_axis()bmat()degrees()tan()apply_over_axes()eye()radians()sinh()argmin()roll()npv()cosh()argmax()identity()fv()tanh()nanargmin()arange()pv()arcsin()nanargmax()place()power()arccos()amax()extract()float_power()exp()amin()compress()log()exp2()insert()rot90()log1()fix()delete()tile()log2()logical_or()append()reshape()log10()logical_and()around()ravel()dot()logical_not()flip()isinf()vdot()logical_xor()fliplr()isrealobj()trunc()array_equal()flipud()isscalar()divide()array_equiv()triu()isneginf()floor_divide()arctan2()tril()isposinf()true_divide()equal()tri()iscomplex()random.rand()not_equal()empty()isnan()random.randn()less()empty_like()iscomplexobj()ndarray.flat()less_equal()zeros()isreal()expm1()greater()zeros_like()isfinite()bincount()greater_equal()ones()isfortran()rint()prod()arctan()cbrt()square() Comment More info A anushka_jain_gfg Follow Improve Article Tags : Numpy Python-numpy Explore NumPy Tutorial - Python Library 3 min read IntroductionNumPy Introduction 7 min read Python NumPy 6 min read NumPy Array in Python 2 min read Basics of NumPy Arrays 4 min read Numpy - ndarray 3 min read Data type Object (dtype) in NumPy Python 3 min read Creating NumPy ArrayNumpy - Array Creation 5 min read numpy.arange() in Python 2 min read numpy.zeros() in Python 2 min read NumPy - Create array filled with all ones 2 min read NumPy - linspace() Function 2 min read numpy.eye() in Python 2 min read Creating a one-dimensional NumPy array 2 min read How to create an empty and a full NumPy array 2 min read Create a Numpy array filled with all zeros - Python 2 min read How to generate 2-D Gaussian array using NumPy? 2 min read How to create a vector in Python using NumPy 4 min read Python - Numpy fromrecords() method 2 min read NumPy Array ManipulationNumPy Copy and View of Array 4 min read How to Copy NumPy array into another array? 2 min read Appending values at the end of an NumPy array 4 min read How to swap columns of a given NumPy array? 4 min read Insert a new axis within a NumPy array 4 min read numpy.hstack() in Python 2 min read numpy.vstack() in python 2 min read Joining NumPy Array 3 min read Combining a One and a Two-Dimensional NumPy Array 3 min read Numpy np.ma.concatenate() method-Python 2 min read Numpy dstack() method-Python 2 min read Splitting Arrays in NumPy 6 min read How to compare two NumPy arrays? 2 min read Find the union of two NumPy arrays 2 min read Find unique rows in a NumPy array 3 min read Numpy np.unique() method-Python 2 min read numpy.trim_zeros() in Python 2 min read Matrix in NumPyMatrix manipulation in Python 4 min read numpy matrix operations | empty() function 1 min read numpy matrix operations | zeros() function 2 min read numpy matrix operations | ones() function 2 min read numpy matrix operations | eye() function 2 min read numpy matrix operations | identity() function 1 min read Adding and Subtracting Matrices in Python 2 min read Matrix Multiplication in NumPy 2 min read Numpy ndarray.dot() function | Python 2 min read NumPy | Vector Multiplication 4 min read How to calculate dot product of two vectors in Python? 3 min read Multiplication of two Matrices in Single line using Numpy in Python 3 min read Numpy np.eigvals() method - Python 1 min read How to Calculate the determinant of a matrix using NumPy? 2 min read Python | Numpy matrix.transpose() 3 min read Python | Numpy matrix.var() 1 min read Compute the inverse of a matrix using NumPy 2 min read Operations on NumPy ArrayNumpy | Binary Operations 8 min read Numpy | Mathematical Function 9 min read Numpy - String Functions & Operations 5 min read Reshaping NumPy ArrayReshape NumPy Array 5 min read Python | Numpy matrix.resize() 1 min read Python | Numpy matrix.reshape() 1 min read NumPy Array Shape 2 min read Change the dimension of a NumPy array 3 min read numpy.ndarray.resize() function - Python 1 min read Flatten a Matrix in Python using NumPy 1 min read numpy.moveaxis() function | Python 2 min read numpy.swapaxes() function - Python 2 min read Python | Numpy matrix.swapaxes() 1 min read numpy.vsplit() function | Python 2 min read numpy.hsplit() function | Python 2 min read Numpy MaskedArray.reshape() function | Python 3 min read Python | Numpy matrix.squeeze() 1 min read Indexing NumPy ArrayBasic Slicing and Advanced Indexing in NumPy 5 min read numpy.compress() in Python 2 min read Accessing Data Along Multiple Dimensions Arrays in Python Numpy 3 min read How to access different rows of a multidimensional NumPy array? 3 min read numpy.tril_indices() function | Python 1 min read Arithmetic operations on NumPyArrayNumPy Array Broadcasting 6 min read Estimation of Variable | set 1 3 min read Python: Operations on Numpy Arrays 3 min read How to use the NumPy sum function? 4 min read numpy.divide() in Python 3 min read numpy.inner() in python 1 min read Absolute Deviation and Absolute Mean Deviation using NumPy | Python 3 min read Calculate standard deviation of a Matrix in Python 2 min read numpy.gcd() in Python 2 min read Linear Algebra in NumPy ArrayNumpy | Linear Algebra 6 min read Get the QR factorization of a given NumPy array 2 min read How to get the magnitude of a vector in NumPy? 3 min read How to compute the eigenvalues and right eigenvectors of a given square array using NumPY? 2 min read Like