Hi everybody,

To continue our series of Python libraries, today, I would like to introduce to you Numpy which is also known as one of the famous scientific computing libraries in Python. Some of you may be familiar with MATLAB before and know how efficient it is when performing calculations with matrices.

Numpy helps us do the same by supporting tools to manage and manipulate multi-dimensional arrays such as matrices. It plays a vital role in the field of computing. Most of the time, when I was working with Machine Learning, I often used Numpy (along with Scipy sometimes) to manipulate the data (such as concatenate two set of data or remove outliers) before fitting it into a model. Of course, there are other libraries help you process the data easier. One of the examples of this is Pandas which is one of the emerging stars in financial data analysis. However, I was familiar with MATLAB when I was a student in an engineering school and feel more conventional when using Numpy. Moreover, I assure you that if you are familiar with Numpy, it will not be difficult for you to turn to use another kind of scientific computing libraries such as Pandas mentioned above.

In fact, Numpy is used for not only linear algebra but also signal processing and statistics. However, these two last are beyond the scope of this tutorial, and I will talk about them later in another.

Now, before rolling up your sleeves to explore how miracle Numpy is, we first need to install it.


The version of Python I use in this tutorial is 2.7.11. However, you can also use all syntaxes for others, regardless the version of 3.* or 2.*.

To install Numpy, there are 2 ways:

Using source file

The first is to access the link: https://sourceforge.net/projects/numpy/files/NumPy/. Then download and install the version that is suitable for your Python version (2.* or 3*) and your operating system (Window, Linux, or MacOS).

Using “pip”

The second way is to use “pip” command. If you have not yet been familiar with “pip” or don’t know what it is. It is OK. Please refer my tutorial on how to install and use “pip” in Python.

Now, open your command window and run this command:

pip install numpy

for Python version 2.* or this command

pip3 install numpy

for Python version 3.*.

If it is not successful for Linux. Try to use

sudo pip install numpy


sudo pip3 install numpy

for the Python version 2.* or 3.*, respectively.

Basic linear algebra with Numpy

First, try to create some vectors and matrices yourself with Numpy.

Next, use some Numpy built-in methods to create some special matrices.

Then, let’s try to use some operators (such as addition, subtraction, or dot product) between two matrices.

And other performance like concatenate two arrays or reshape one.

That’s all about basic linear algebra with the Numpy library that I would like to talk about, by which, you could do a lot of things in data analysis. Of course, what presented above is not all of Numpy. There is more and more miracle that the Numpy can do such as analyzing statistics or processing a signal. For more details, you could find and read its documentation.

In the next tutorial, you will learn how to visualize data and plot some basic graphs (such as the line or bar chart) by using a popular library named Matplotlib. In this post, I promise we will draw some fun with math functions I found on the Internet. Until then, hope you enjoy my posts.

See ya,

Curious Chick


Author: curiouschick

There are many things you may never know about me. But, two things you absolutely know when you visit my blog for the first time: I am a chick and really curious to know everything.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s