Install Jupyter Pandas Matplotlib

How to install Jupyter Pandas Matplotlib on our machine?  Firstly, let’s start with the Jupyter Notebook on Ubuntu that I use.

On that account you need to open your terminal and type a few commands.

And that’s all you need to do.

In this section we will take a close look at this topic and finally we will use Pandas to read a CSV file and retrieve a dataframe.

First thing first. We will need to have Python and pip, the package manager for Python, installed on our system. 

If we do not have these prerequisites already installed, we can install them by running the following commands:

sudo apt-get update
sudo apt-get install python3

Next we will install pip issuing the following command.

sudo apt-get install python3-pip

Once we have Python and pip installed, we can use pip to install Jupyter Notebook by running the following command:

pip3 install jupyter

In some cases, after issuing this command the system asks us to issue another command to install the Jupyter Notebook.

sudo apt install jupyter-notebook

Next we launch Jupyter by opening a terminal and run the following command:

jupyter-notebook

While opening the Jupyter Notebook we see something like the following image.

Jupyter Notebook installed locally
Jupyter Notebook installed locally

However, if you are new, please go to the top right section and click the ‘New’ tab. From there we need to click the Python 3 selector and that will open the Jupyter Notebook to write our code.

Actually, this will open a new tab in our web browser with the Jupyter Notebook interface. 

Now we can create and edit notebooks from this interface.

Usually this will install Jupyter and all of its dependencies. But that doesn’t ensure that we have Pandas, and Matplotlib.

Being so, we need to install Pandas and Matplotlib separately.

So get started.

To install Pandas, we use pip by running the following command:

pip3 install pandas

This will install the latest version of pandas and its dependencies.

It will also install NumPy, another important library we need for machine learning.

Alternatively, we can also install pandas using the package manager apt. 

To do that we update the package index by running the following command:

sudo apt update

Then we install pandas by running the following command:

sudo apt install python3-pandas

This will install the latest version of pandas available in the default repositories.

Once the installation is over, we can check the version of pandas that was installed by running the following command:

pandas --version

Now we import the Pandas library to our local Jupyter Notebook interface by writing the following command.

Besides, we can read the CSV file and get our first DataFrame.

import pandas as pd

df = pd.read_csv('https://raw.githubusercontent.com/sanjibsinha/Machine-Learning-Primer/main/Mental%20health%20Depression%20disorder%20Data.csv')

df.head()

Side by side we can install Matplotlib in Ubuntu.

All we will need to have is the Python installed on our system. 

That we have already. Therefore, we can use pip, the Python package manager, to install Matplotlib. Run the following command to install Matplotlib:

pip3 install matplotlib

That’s it! Matplotlib should now be installed on our system and we can start using it in your Python scripts.

column = df.iloc[:100, df.columns.get_loc('Anxiety disorders (%)')]
column

# output
0     4.828830
1     4.829740
2     4.831108
3     4.830864
4     4.829423
        ...   
95    3.289246
96    3.290960
97    3.292664
98    3.294261
99    3.295744
Name: Anxiety disorders (%), Length: 100, dtype: float64

Next we can use Matplotlib to visualize data.

For example, we have a huge dataset of Medical records based on each country between years.

As a result, the visualization may take some time.

Jupyter Notebook installed locally and we visualize data
Jupyter Notebook installed locally and we visualize data

Consequently, we have successfully installed Jupyter Pandas Matplotlib in our machine.

For more such data science and machine learning related code, please visit our GitHub Repository.

What Next?

Books at Leanpub

Books in Apress

My books at Amazon

GitHub repository

TensorFlow, Machine Learning, AI and Data Science

Flutter, Dart and Algorithm

C, C++, Java and Game Development

Twitter

Comments

Leave a Reply