Categories
Python

How to Install pandas on Ubuntu 20.04

Here you will learn 3 ways to install pandas on Ubuntu 20.04 through apt or pip or conda. Specifically, you will also learn how to install Python 3 and Python package manager, either pip or conda (Anaconda or Miniconda).

pandas & Ubuntu 20.04

Pandas is a fast, efficient, modular and easy-to-use open source framework for data analysis and manipulation. It’s designed on top of the Python programming language and thus Pandas is pythonic.

Code-named Focal Fossa, Ubuntu 20.04 is the most recent release of Ubuntu LTS. It is out in April 2020 and supported for 5 years until April 2025 (standard support).

Ubuntu 20.04 also includes Python 3 by default, so you don’t need to install it as well. This is a mandate move because the Python Foundation already announced the EOL of Python 2, which is on Jan 1, 2020. In the older Ubuntu versions, Python 2 is the default and typing python in the terminal will bring you to Python 2, which means we have to type python3 to use Python 3. Now you can install python-is-python3, which will set python to python3.

Method 1 — Install python3-pandas system package

The first method is to install the python3-pandas system package on Ubuntu 20.04. The version might be outdated but usually comes with less bugs which may be introduced in later versions. Here is the information about python3-pandas:

Package: python3-pandas
Version: 0.25.3+dfsg-7
Priority: optional
Section: universe/python
Source: pandas
Origin: Ubuntu
Maintainer: Ubuntu Developers ubuntu-devel-discuss@lists.ubuntu.com
Original-Maintainer: Debian Science Team debian-science-maintainers@lists.alioth.debian.org
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 14.3 MB
Depends: python3 (<< 3.9), python3 (>= 3.8~), python3-dateutil, python3-numpy (>= 1:1.15~), python3-tz, python3:any, python3-pandas-lib (>= 0.25.3+dfsg-7), python3-pkg-resources, python3-six
Recommends: python3-scipy, python3-matplotlib, python3-numexpr, python3-tables, python3-xlrd, python3-openpyxl, python3-xlwt, python3-bs4, python3-html5lib, python3-lxml
Suggests: python-pandas-doc, python3-statsmodels
Breaks: cnvkit (<< 0.9.6-1.1), python3-feather-format (<< 0.3.1+dfsg1-2.1), python3-skbio (<< 0.5.5-2.1), python3-statsmodels (<< 0.10.0~), q2-types (<< 2019.7.0-1.1)
Homepage: https://pandas.pydata.org/
Download-Size: 1,968 kB
APT-Sources: http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages
Description: data structures for "relational" or "labeled" data
pandas is a Python package providing fast, flexible, and expressive
data structures designed to make working with "relational" or
"labeled" data both easy and intuitive. It aims to be the fundamental
high-level building block for doing practical, real world data
analysis in Python. pandas is well suited for many different kinds of
data:
.
Tabular data with heterogeneously-typed columns, as in an SQL
table or Excel spreadsheet
Ordered and unordered (not necessarily fixed-frequency) time
series data.
Arbitrary matrix data (homogeneously typed or heterogeneous) with
row and column labels
Any other form of observational / statistical data sets. The data
actually need not be labeled at all to be placed into a pandas
data structure
.
This package contains the Python 3 version.

To install the package, run the following apt install command and press “Y” to continue the installation:

sudo apt install python3-pandas

You will see the output like the screenshot below (all text is pasted after the screenshot). Python 3 and numpy will be installed as well if you don’t have it in your system. As you see below, it will take 100 MB of your disk.

Running sudo apt install python3 pandas on Ubuntu 20.04
vh@varhowto-com:~$ sudo apt install python3-pandas
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
libblosc1 liblbfgsb0 python-tables-data
python3-atomicwrites python3-bs4 python3-decorator
python3-et-xmlfile python3-html5lib
python3-importlib-metadata python3-jdcal python3-lxml
python3-more-itertools python3-numexpr python3-openpyxl
python3-packaging python3-pandas-lib python3-pluggy
python3-py python3-pytest python3-scipy
python3-soupsieve python3-tables python3-tables-lib
python3-wcwidth python3-webencodings python3-xlrd
python3-xlwt python3-zipp
Suggested packages:
python3-genshi python3-lxml-dbg python-lxml-doc
python-pandas-doc python3-statsmodels subversion
python-scipy-doc python3-netcdf4 python-tables-doc
vitables python-xlrt-doc
The following NEW packages will be installed:
libblosc1 liblbfgsb0 python-tables-data
python3-atomicwrites python3-bs4 python3-decorator
python3-et-xmlfile python3-html5lib
python3-importlib-metadata python3-jdcal python3-lxml
python3-more-itertools python3-numexpr python3-openpyxl
python3-packaging python3-pandas python3-pandas-lib
python3-pluggy python3-py python3-pytest python3-scipy
python3-soupsieve python3-tables python3-tables-lib
python3-wcwidth python3-webencodings python3-xlrd
python3-xlwt python3-zipp
0 upgraded, 29 newly installed, 0 to remove and 49 not upgraded.
Need to get 21.1 MB of archives.
After this operation, 100 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 libblosc1 amd64 1.17.1+ds1-1 [32.2 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/universe amd64 liblbfgsb0 amd64 3.0+dfsg.3-7build1 [29.5 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal/universe amd64 python-tables-data all 3.6.1-2build1 [45.7 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal/universe amd64 python3-atomicwrites all 1.1.5-2build1 [7,016 B]
Get:5 http://archive.ubuntu.com/ubuntu focal/main amd64 python3-soupsieve all 1.9.5+dfsg-1 [29.1 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal/main amd64 python3-bs4 all 4.8.2-1 [83.0 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal/main amd64 python3-decorator all 4.4.2-0ubuntu1 [10.3 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal/universe amd64 python3-et-xmlfile all 1.0.1-2.1 [9,224 B]
Get:9 http://archive.ubuntu.com/ubuntu focal/main amd64 python3-webencodings all 0.5.1-1ubuntu1 [11.0 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal/main amd64 python3-html5lib all 1.0.1-2 [84.3 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal/main amd64 python3-more-itertools all 4.2.0-1build1 [39.4 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal/main amd64 python3-zipp all 1.0.0-1 [5,312 B]
Get:13 http://archive.ubuntu.com/ubuntu focal/main amd64 python3-importlib-metadata all 1.5.0-1 [9,992 B]
Get:14 http://archive.ubuntu.com/ubuntu focal/universe amd64 python3-jdcal all 1.0-1.3 [7,944 B]
Get:15 http://archive.ubuntu.com/ubuntu focal/main amd64 python3-lxml amd64 4.5.0-1 [1,381 kB]
Get:16 http://archive.ubuntu.com/ubuntu focal/universe amd64 python3-numexpr amd64 2.7.1-1build1 [133 kB]
Get:17 http://archive.ubuntu.com/ubuntu focal/universe amd64 python3-openpyxl all 3.0.3-1 [144 kB]
Get:18 http://archive.ubuntu.com/ubuntu focal/main amd64 python3-packaging all 20.3-1 [26.8 kB]
Get:19 http://archive.ubuntu.com/ubuntu focal/universe amd64 python3-pandas-lib amd64 0.25.3+dfsg-7 [4,628 kB]
Get:20 http://archive.ubuntu.com/ubuntu focal/universe amd64 python3-pandas all 0.25.3+dfsg-7 [1,968 kB]
Get:21 http://archive.ubuntu.com/ubuntu focal/universe amd64 python3-pluggy all 0.13.0-2 [18.4 kB]
Get:22 http://archive.ubuntu.com/ubuntu focal/universe amd64 python3-py all 1.8.1-1 [65.4 kB]
Get:23 http://archive.ubuntu.com/ubuntu focal/main amd64 python3-wcwidth all 0.1.8+dfsg1-3 [17.4 kB]
Get:24 http://archive.ubuntu.com/ubuntu focal/universe amd64 python3-pytest all 4.6.9-1 [178 kB]
Get:25 http://archive.ubuntu.com/ubuntu focal/universe amd64 python3-tables-lib amd64 3.6.1-2build1 [501 kB]
Get:26 http://archive.ubuntu.com/ubuntu focal/universe amd64 python3-tables all 3.6.1-2build1 [333 kB]
Get:27 http://archive.ubuntu.com/ubuntu focal/universe amd64 python3-xlrd all 1.1.0-5 [90.8 kB]
Get:28 http://archive.ubuntu.com/ubuntu focal/universe amd64 python3-xlwt all 1.3.0-3 [83.7 kB]
Get:29 http://archive.ubuntu.com/ubuntu focal/universe amd64 python3-scipy amd64 1.3.3-3build1 [11.1 MB]
Fetched 21.1 MB in 3s (7,641 kB/s)
Selecting previously unselected package libblosc1.
(Reading database … 284168 files and directories currently install
ed.)
Preparing to unpack …/00-libblosc1_1.17.1+ds1-1_amd64.deb …
Unpacking libblosc1 (1.17.1+ds1-1) …
Selecting previously unselected package liblbfgsb0:amd64.
Preparing to unpack …/01-liblbfgsb0_3.0+dfsg.3-7build1_amd64.deb .
..
Unpacking liblbfgsb0:amd64 (3.0+dfsg.3-7build1) …
Selecting previously unselected package python-tables-data.
Preparing to unpack …/02-python-tables-data_3.6.1-2build1_all.deb
…
Unpacking python-tables-data (3.6.1-2build1) …
Selecting previously unselected package python3-atomicwrites.
Preparing to unpack …/03-python3-atomicwrites_1.1.5-2build1_all.de
b …
Unpacking python3-atomicwrites (1.1.5-2build1) …
Selecting previously unselected package python3-soupsieve.
Preparing to unpack …/04-python3-soupsieve_1.9.5+dfsg-1_all.deb ..
.
Unpacking python3-soupsieve (1.9.5+dfsg-1) …
Selecting previously unselected package python3-bs4.
Preparing to unpack …/05-python3-bs4_4.8.2-1_all.deb …
Unpacking python3-bs4 (4.8.2-1) …
Selecting previously unselected package python3-decorator.
Preparing to unpack …/06-python3-decorator_4.4.2-0ubuntu1_all.deb
…
Unpacking python3-decorator (4.4.2-0ubuntu1) …
Selecting previously unselected package python3-et-xmlfile.
Preparing to unpack …/07-python3-et-xmlfile_1.0.1-2.1_all.deb …
Unpacking python3-et-xmlfile (1.0.1-2.1) …
Selecting previously unselected package python3-webencodings.
Preparing to unpack …/08-python3-webencodings_0.5.1-1ubuntu1_all.d
eb …
Unpacking python3-webencodings (0.5.1-1ubuntu1) …
Selecting previously unselected package python3-html5lib.
Preparing to unpack …/09-python3-html5lib_1.0.1-2_all.deb …
Unpacking python3-html5lib (1.0.1-2) …
Selecting previously unselected package python3-more-itertools.
Preparing to unpack …/10-python3-more-itertools_4.2.0-1build1_all.
deb …
Unpacking python3-more-itertools (4.2.0-1build1) …
Selecting previously unselected package python3-zipp.
Preparing to unpack …/11-python3-zipp_1.0.0-1_all.deb …
Unpacking python3-zipp (1.0.0-1) …
Selecting previously unselected package python3-importlib-metadata.
Preparing to unpack …/12-python3-importlib-metadata_1.5.0-1_all.de
b …
Unpacking python3-importlib-metadata (1.5.0-1) …
Selecting previously unselected package python3-jdcal.
Preparing to unpack …/13-python3-jdcal_1.0-1.3_all.deb …
Unpacking python3-jdcal (1.0-1.3) …
Selecting previously unselected package python3-lxml:amd64.
Preparing to unpack …/14-python3-lxml_4.5.0-1_amd64.deb …
Unpacking python3-lxml:amd64 (4.5.0-1) …
Selecting previously unselected package python3-numexpr.
Preparing to unpack …/15-python3-numexpr_2.7.1-1build1_amd64.deb .
..
Unpacking python3-numexpr (2.7.1-1build1) …
Selecting previously unselected package python3-openpyxl.
Preparing to unpack …/16-python3-openpyxl_3.0.3-1_all.deb …
Unpacking python3-openpyxl (3.0.3-1) …
Selecting previously unselected package python3-packaging.
Preparing to unpack …/17-python3-packaging_20.3-1_all.deb …
Unpacking python3-packaging (20.3-1) …
Selecting previously unselected package python3-pandas-lib.
Preparing to unpack …/18-python3-pandas-lib_0.25.3+dfsg-7_amd64.de
b …
Unpacking python3-pandas-lib (0.25.3+dfsg-7) …
Selecting previously unselected package python3-pandas.
Preparing to unpack …/19-python3-pandas_0.25.3+dfsg-7_all.deb …
Unpacking python3-pandas (0.25.3+dfsg-7) …
Selecting previously unselected package python3-pluggy.
Preparing to unpack …/20-python3-pluggy_0.13.0-2_all.deb …
Unpacking python3-pluggy (0.13.0-2) …
Selecting previously unselected package python3-py.
Preparing to unpack …/21-python3-py_1.8.1-1_all.deb …
Unpacking python3-py (1.8.1-1) …
Selecting previously unselected package python3-wcwidth.
Preparing to unpack …/22-python3-wcwidth_0.1.8+dfsg1-3_all.deb …
Unpacking python3-wcwidth (0.1.8+dfsg1-3) …
Selecting previously unselected package python3-pytest.
Preparing to unpack …/23-python3-pytest_4.6.9-1_all.deb …
Unpacking python3-pytest (4.6.9-1) …
Selecting previously unselected package python3-tables-lib.
Preparing to unpack …/24-python3-tables-lib_3.6.1-2build1_amd64.de
b …
Unpacking python3-tables-lib (3.6.1-2build1) …
Selecting previously unselected package python3-tables.
Preparing to unpack …/25-python3-tables_3.6.1-2build1_all.deb …
Unpacking python3-tables (3.6.1-2build1) …
Selecting previously unselected package python3-xlrd.
Preparing to unpack …/26-python3-xlrd_1.1.0-5_all.deb …
Unpacking python3-xlrd (1.1.0-5) …
Selecting previously unselected package python3-xlwt.
Preparing to unpack …/27-python3-xlwt_1.3.0-3_all.deb …
Unpacking python3-xlwt (1.3.0-3) …
Selecting previously unselected package python3-scipy.
Preparing to unpack …/28-python3-scipy_1.3.3-3build1_amd64.deb …
Unpacking python3-scipy (1.3.3-3build1) …
Setting up python3-more-itertools (4.2.0-1build1) …
Setting up python3-py (1.8.1-1) …
Setting up python3-jdcal (1.0-1.3) …
Setting up python3-pandas-lib (0.25.3+dfsg-7) …
Setting up python3-zipp (1.0.0-1) …
Setting up python3-webencodings (0.5.1-1ubuntu1) …
Setting up python3-atomicwrites (1.1.5-2build1) …
Setting up python3-decorator (4.4.2-0ubuntu1) …
Setting up python3-packaging (20.3-1) …
Setting up python3-wcwidth (0.1.8+dfsg1-3) …
Setting up python3-pandas (0.25.3+dfsg-7) …
/usr/lib/python3/dist-packages/pandas/tests/frame/test_alter_axes.py
:241: SyntaxWarning: "is" with a literal. Did you mean "=="?
False if (keys[0] is "A" and keys[1] is "A") else drop # noqa: F6
32
/usr/lib/python3/dist-packages/pandas/tests/frame/test_alter_axes.py
:241: SyntaxWarning: "is" with a literal. Did you mean "=="?
False if (keys[0] is "A" and keys[1] is "A") else drop # noqa: F6
32
Setting up python3-xlwt (1.3.0-3) …
Setting up python3-numexpr (2.7.1-1build1) …
Setting up python3-html5lib (1.0.1-2) …
Setting up python3-lxml:amd64 (4.5.0-1) …
Setting up libblosc1 (1.17.1+ds1-1) …
Setting up python3-et-xmlfile (1.0.1-2.1) …
Setting up python3-xlrd (1.1.0-5) …
Setting up python3-soupsieve (1.9.5+dfsg-1) …
Setting up python-tables-data (3.6.1-2build1) …
Setting up liblbfgsb0:amd64 (3.0+dfsg.3-7build1) …
Setting up python3-scipy (1.3.3-3build1) …
Setting up python3-importlib-metadata (1.5.0-1) …
Setting up python3-tables-lib (3.6.1-2build1) …
Setting up python3-tables (3.6.1-2build1) …
Setting up python3-bs4 (4.8.2-1) …
Setting up python3-openpyxl (3.0.3-1) …
Setting up python3-pluggy (0.13.0-2) …
Setting up python3-pytest (4.6.9-1) …
Processing triggers for man-db (2.9.1-1) …
Processing triggers for libc-bin (2.31-0ubuntu9) …

Install panda’s documentation package: python-pandas-doc

After you have install pandas, it is recommended to install the documentation package python-pandas-doc as well. This way, you can easily access panda’s documentation offline without having to go to pandas’ website every time.

To install it, run the following command:

sudo apt install python-pandas-doc

You will see the output like the screenshot below. Press ‘Y’ to continue.

Installing python pandas doc on Ubuntu 20.04 by sudo apt install python pandas doc
vh@varhowto-com:~$ sudo apt install python-pandas-doc
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
fonts-mathjax libjs-mathjax libjs-requirejs
Suggested packages:
fonts-mathjax-extras fonts-stix libjs-mathjax-doc
The following NEW packages will be installed:
fonts-mathjax libjs-mathjax libjs-requirejs
python-pandas-doc
0 upgraded, 4 newly installed, 0 to remove and 49 not upgraded.
Need to get 14.8 MB of archives.
After this operation, 105 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 fonts-mathjax all 2.7.4+dfsg-1 [2,208 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/universe amd64 libjs-requirejs all 2.3.6-1 [29.9 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal/universe amd64 libjs-mathjax all 2.7.4+dfsg-1 [5,654 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal/universe amd64 python-pandas-doc all 0.25.3+dfsg-7 [6,939 kB]
Fetched 14.8 MB in 2s (6,886 kB/s)
Selecting previously unselected package fonts-mathjax.
(Reading database … 287140 files and directories currently installed.)
Preparing to unpack …/fonts-mathjax_2.7.4+dfsg-1_all.deb …
Unpacking fonts-mathjax (2.7.4+dfsg-1) …
Selecting previously unselected package libjs-requirejs.
Preparing to unpack …/libjs-requirejs_2.3.6-1_all.deb …
Unpacking libjs-requirejs (2.3.6-1) …
Selecting previously unselected package libjs-mathjax.
Preparing to unpack …/libjs-mathjax_2.7.4+dfsg-1_all.deb …
Unpacking libjs-mathjax (2.7.4+dfsg-1) …
Selecting previously unselected package python-pandas-doc.
Preparing to unpack …/python-pandas-doc_0.25.3+dfsg-7_all.deb …
Unpacking python-pandas-doc (0.25.3+dfsg-7) …
Setting up fonts-mathjax (2.7.4+dfsg-1) …
Setting up libjs-mathjax (2.7.4+dfsg-1) …
Setting up libjs-requirejs (2.3.6-1) …
Setting up python-pandas-doc (0.25.3+dfsg-7) …
Processing triggers for fontconfig (2.13.1-2ubuntu3) …

Then you can click this link or copy it to your browser to see panda’s documentation: /usr/share/doc/python-pandas-doc/html/index.html.

pandas documentation on Ubuntu 20.04

Method 2 — Install pandas with pip on Ubuntu 20.04

Sometimes, it is prefered to use a Python package manager to install pandas, especially if you want to use the latest pandas version. pandas has recently been updated to version 1 and the one in Ubuntu 20.04’s official repo is still 0.25.3.

Step 1 — Install pip3 (and Python3)

There are 2 major Python package managers. The first is the official one called Pip, and another one is Conda (Anaconda or Miniconda). When in doubt or for beginners, the official pip is recommended.

Install Python 3 and pip for pandas

Pip is the native Python package manager. We will use it to install pandas. To install pip3, run the following command. Because pip3 depends on Python 3, python3 will also be installed if it is not in your Ubuntu 20.04 system.

sudo apt install python3-pip

You will see output similar to the screenshot below. Press “Y” to continue. As you may notice, it will also install python-pip-whl and python3-wheel, where wheel is the built-package format for Python.

Install pip 3 for PyTorch

Here is the full output for the pip3 installation:

vh@varhowto-com:~$ sudo apt install python3-pip
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
python-pip-whl python3-wheel
The following NEW packages will be installed:
python-pip-whl python3-pip python3-wheel
0 upgraded, 3 newly installed, 0 to remove and 49 not upgraded.
Need to get 2,053 kB of archives.
After this operation, 3,455 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 python-pip-whl all 20.0.2-5ubuntu1 [1,799 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/universe amd64 python3-wheel all 0.34.2-1 [23.8 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal/universe amd64 python3-pip all 20.0.2-5ubuntu1 [230 kB]
Fetched 2,053 kB in 1s (2,104 kB/s)
Selecting previously unselected package python-pip-w
hl.
(Reading database … 273191 files and directories c
urrently installed.)
Preparing to unpack …/python-pip-whl_20.0.2-5ubunt
u1_all.deb …
Unpacking python-pip-whl (20.0.2-5ubuntu1) …
Selecting previously unselected package python3-whee
l.
Preparing to unpack …/python3-wheel_0.34.2-1_all.d
eb …
Unpacking python3-wheel (0.34.2-1) …
Selecting previously unselected package python3-pip.
Preparing to unpack …/python3-pip_20.0.2-5ubuntu1_
all.deb …
Unpacking python3-pip (20.0.2-5ubuntu1) …
Setting up python3-wheel (0.34.2-1) …
Setting up python-pip-whl (20.0.2-5ubuntu1) …
Setting up python3-pip (20.0.2-5ubuntu1) …
Processing triggers for man-db (2.9.1-1) …

[Alternative] Install Conda (Anoconda/Miniconda) for pandas

Step 2 — Install pandas using pip

To install pandas from PyPI (pip), run the following command:

pip3 install pandas

Note that if you have install pandas using the first method, you will need to uninstall pandas using sudo apt remove python3-pandas, otherwise you will see the output: “Requirement already satisfied: pandas in /usr/lib/python3/dist-packages (0.25.3)”, which means you are not getting the latest version of pandas.

the latest version of pandas is not installed if installed the system version

You will see the following output in your terminal. As you see from the last line, I just installed pandas 1.1.0 on my Ubuntu 20.04 OS. Your version number might be bigger as pandas releases new versions.

Collecting pandas
Downloading pandas-1.1.0-cp38-cp38-manylinux1_x86_64.whl (10.3 MB)
Requirement already satisfied: python-dateutil>=2.7.3 in /usr/lib/python3/dist-packages (from pandas) (2.7.3)
Requirement already satisfied: pytz>=2017.2 in /usr/lib/python3/dist-packages (from pandas) (2019.3)
Requirement already satisfied: numpy>=1.15.4 in /usr/lib/python3/dist-packages (from pandas) (1.17.4)
Installing collected packages: pandas
Successfully installed pandas-1.1.0

Method 3 — Install pandas with conda (Miniconda/Anaconda)

There is another popular Python package distribution called Anaconda or Miniconda. You can also use it to install pandas.

We have previously written a tutorial to install Miniconda, you can read it if you prefer conda or just want to learn more. Note that conda distributes python itself, so it won’t use the system Python and you won’t need to have Python installed before installing conda.

Ton install pandas with conda, run the following command. When asked “Proceed ([y]/n)?”, press y and enter to continue.

conda install pandas

You will see the following output:

Installing pandas using conda on Ubuntu 20.04

Here is the full output:

(base) vh@varhowto-com:~$ conda install pandas
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /home/vh/miniconda3

  added / updated specs:
    - pandas


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    blas-1.0                   |              mkl           6 KB
    ca-certificates-2020.6.24  |                0         125 KB
    certifi-2020.6.20          |           py38_0         156 KB
    intel-openmp-2020.1        |              217         780 KB
    mkl-2020.1                 |              217       129.0 MB
    mkl-service-2.3.0          |   py38he904b0f_0          62 KB
    mkl_fft-1.1.0              |   py38h23d657b_0         150 KB
    mkl_random-1.1.1           |   py38h0573a6f_0         341 KB
    numpy-1.19.1               |   py38hbc911f0_0          21 KB
    numpy-base-1.19.1          |   py38hfa32c7d_0         4.2 MB
    pandas-1.1.0               |   py38he6710b0_0         8.4 MB
    python-dateutil-2.8.1      |             py_0         215 KB
    pytz-2020.1                |             py_0         184 KB
    ------------------------------------------------------------
                                           Total:       143.6 MB

The following NEW packages will be INSTALLED:

  blas               pkgs/main/linux-64::blas-1.0-mkl
  intel-openmp       pkgs/main/linux-64::intel-openmp-2020.1-217
  mkl                pkgs/main/linux-64::mkl-2020.1-217
  mkl-service        pkgs/main/linux-64::mkl-service-2.3.0-py38he904b0f_0
  mkl_fft            pkgs/main/linux-64::mkl_fft-1.1.0-py38h23d657b_0
  mkl_random         pkgs/main/linux-64::mkl_random-1.1.1-py38h0573a6f_0
  numpy              pkgs/main/linux-64::numpy-1.19.1-py38hbc911f0_0
  numpy-base         pkgs/main/linux-64::numpy-base-1.19.1-py38hfa32c7d_0
  pandas             pkgs/main/linux-64::pandas-1.1.0-py38he6710b0_0
  python-dateutil    pkgs/main/noarch::python-dateutil-2.8.1-py_0
  pytz               pkgs/main/noarch::pytz-2020.1-py_0

The following packages will be UPDATED:

  ca-certificates                                2020.1.1-0 --> 2020.6.24-0
  certifi                                 2020.4.5.1-py38_0 --> 2020.6.20-py38_0


Proceed ([y]/n)? y


Downloading and Extracting Packages
blas-1.0             | 6 KB      | ###################################### | 100% 
mkl-2020.1           | 129.0 MB  | ###################################### | 100% 
pytz-2020.1          | 184 KB    | ###################################### | 100% 
intel-openmp-2020.1  | 780 KB    | ###################################### | 100% 
mkl-service-2.3.0    | 62 KB     | ###################################### | 100% 
ca-certificates-2020 | 125 KB    | ###################################### | 100% 
mkl_random-1.1.1     | 341 KB    | ###################################### | 100% 
numpy-base-1.19.1    | 4.2 MB    | ###################################### | 100% 
python-dateutil-2.8. | 215 KB    | ###################################### | 100% 
pandas-1.1.0         | 8.4 MB    | ###################################### | 100% 
mkl_fft-1.1.0        | 150 KB    | ###################################### | 100% 
certifi-2020.6.20    | 156 KB    | ###################################### | 100% 
numpy-1.19.1         | 21 KB     | ###################################### | 100% 
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

Verify pandas installation

Now you have pandas installed on your Ubuntu 20.04 computer. How to check if pandas is installed correctly? Run python3 and copy/paster the following code.

import pandas as pd
s = pd.Series([1, 6, 8, 10])
s

You should be able to see something similar to the following screenshot:

Checking if pandas is installed on Ubuntu 20.04

Here is the full text from the terminal:

(base) vh@varhowto-com:~$ python3
Python 3.8.3 (default, May 19 2020, 18:47:26)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
import pandas as pd
s = pd.Series([1, 6, 8, 10])
s
0 1
1 6
2 8
3 10
dtype: int64

[Sumarry] 3 ways to install pandas on Ubuntu 20.04

Time Needed : 5 minutes

  1. [Ubuntu package] Install python3-pandas system package

    Run sudo apt install python3-pandas to install pandas from Ubuntu 20.04's official repositoryRunning sudo apt install python3 pandas on Ubuntu 20.04

  2. [pip] Install pandas using pip3 on Ubuntu 20.04

    Run sudo apt install python3-pip to install pip3 and Python 3 if they are not installed.

    Run pip3 install pandas to install pandas as a pyPI package.the latest version of pandas is not installed if installed the system version

  3. [conda] Install pandas with Anaconda/Miniconda

    Run conda install pandas after you have install conda in Ubuntu 20.04.Installing pandas using conda on Ubuntu 20.04

24

By VarHowto Editor

Welcome to VarHowto!

3 replies on “How to Install pandas on Ubuntu 20.04”

I followed the directions, but I get an error message that there is no dateutil module or pytz module. The installation indicates that the modules are present, but running a program with pandas cannot find the modules. The program used to work with UBUNTU 18.04, but not after upgrade to UBUNTU 20.04. Any suggestions?

+2

Hi,
I just wanted to point out that you wrote in summary command “pip install pandas” while on the screen is the correct version “pip3 install pandas”.
Best wishes,
Karol

+1

Comments are closed.