Most used functions in NumPy

Useful functions in NumPy for Data Science and Machine Learning

Aviral Bhardwaj
4 min readAug 11, 2022

Numpy is one of the most used and popular python library which is used for many purposes along with data analysis and support for data structures.

In this article, we will discuss the most popular and widely used numpy functions, which will definitely save us time and provide us with more insights into the dataset.

Importing the libraries

Now we will import numpy as shown below. If your system does not have these libraries installed, you may get them using the pip command.

Array

Array function can create an array. We can create an array by providing a list i.e. np.array(list).

Reshape

Reshape function is used to reshape the array into the provided shape. We can use this function by array.reshape(new shape).

Sort

Sort function can sort the array in ascending or descending order. We can sort our array by array.sort().

Unique

Unique function return all the unique elements present in the list. We can use this function by np.unique(array).

Arange

Arange function creates an integer array with evenly spaced intervals. We can use this function by np.arange(low,high,interval).

Linspace

Linespace function creates a float array with evenly spaced numbers. We can use this function by np.linspace(low,high,interval).

Put

Put functions replaces the value present in the array by new values. We can use this function by np.put(array, position, new value).

Min and Max

Min and Max function returns the minimum and maximum value in the array. We can use np.min(array) and np.max(array).

Sum

Sum function returns the sum of elements present in the array. We can use this function by np.sum(array).

Around

Around function rounds off the provided number to appropriate integer. We can use this function by np.around(array).

Random integers

Random function is used to return an array of given size between the provided range. We can use this function by np.random.randint(initial value, final value, size).

Random shuffle

Random shuffle function is used to shuffle an array and return an array with shuffled elements. We can shuffle our array by np.random.shuffle(array).

Well, if you like this article you can check out my articles for more interesting articles in the field of artificial intelligence and machine learning.

Conclusion

If you found this article useful please appreciate it by giving claps and follow me for more interesting articles. Well, I have good news for you I would be bringing more articles to explain machine learning concepts and models with codes so leave a comment and tell me how excited are you about this.

--

--

Aviral Bhardwaj

One of the youngest writer and mentor on AI-ML & Technology.