How to Check the Pandas Version in Your Script?

4.6/5 - (5 votes)
How to Check the Pandas Version in Your Script?

What is the Pandas Library?

The pandas library provides data structures and functionality to represent and manipulate labelled and tabular data.

Think of it as like an advanced spreadsheet program in your code with functionality includingβ€”but not limited to:

  • creating spreadsheets,
  • accessing individual rows by name,
  • calculating basic statistics over rows and columns, and
  • summing over cells that fulfill a certain condition.

How to Check Your Pandas Version in Your Script?

To check the pandas version running in your script, run two commands in your shell:

  1. Import the library with import pandas as pd, and
  2. Run and print the attribute pd.__version__ to check the pandas version running in your script.

Here’s the code and the output version on my computer:

import pandas as pd

The output in my Python script is:


How to Check Your Pandas Version with Pip? [Terminal, Shell, CMD]

To check your pandas version with pip in your Windows command line, Powershell, macOS terminal, or Linux shell, run pip show pandas. The second line of the output provides your pandas version.

$ pip show pandas
Name: pandas
Version: 1.0.3
Summary: Powerful data structures for data analysis, time series, and statistics
Author: None
Author-email: None
License: BSD
Location: c:\users\xcent\appdata\local\programs\python\python38\lib\site-packages
Requires: numpy, python-dateutil, pytz
Required-by: seaborn, get-all-tickers

Here’s a screenshot on my Windows computer using Powershell:

How to Find the Dependency Versions for Your Given Pandas Version?

Pandas is a complicated library that depends on many external libraries (dependencies) itself.

To check the versions assumed by your current pandas version, run pd.show_versions() that returns a string representation with one dependency version per line.

  • Import the library with import pandas as pd, and
  • Run and print the function pd.show_versions() to check the version of the Pandas running in your script.

Here’s the code:

import pandas as pd

And the output:

commit           : None
python           :
python-bits      : 64
OS               : Windows
OS-release       : 10
machine          : AMD64
processor        : Intel64 Family 6 Model 142 Stepping 11, GenuineIntel
byteorder        : little
LC_ALL           : None
LANG             : None
LOCALE           : de_DE.cp1252

pandas           : 1.0.1
numpy            : 1.19.2
pytz             : 2018.9
dateutil         : 2.8.0
pip              : 20.0.2
setuptools       : 40.6.2
Cython           : None
pytest           : None
hypothesis       : None
sphinx           : None
blosc            : None
feather          : None
xlsxwriter       : None
lxml.etree       : 4.4.2
html5lib         : None
pymysql          : None
psycopg2         : None
jinja2           : 2.10.1
IPython          : None
pandas_datareader: 0.8.1
bs4              : None
bottleneck       : None
fastparquet      : None
gcsfs            : None
lxml.etree       : 4.4.2
matplotlib       : 3.0.2
numexpr          : None
odfpy            : None
openpyxl         : None
pandas_gbq       : None
pyarrow          : None
pytables         : None
pytest           : None
pyxlsb           : None
s3fs             : None
scipy            : 1.2.1
sqlalchemy       : None
tables           : None
tabulate         : None
xarray           : None
xlrd             : 1.2.0
xlwt             : None
xlsxwriter       : None
numba            : None

Resources and Further Reading

You can check the newest pandas versions here:

If you need to get a refresher on pandas, check out my “5-minutes to pandas introduction” on this Finxter blog.

10 Minutes to Pandas in 5 Minutes (Okay 8)

For a more thorough tutorial, check out our in-depth book Coffee Break Pandas (Amazon Link).

Programming Humor – Python

“I wrote 20 short programs in Python yesterday. It was wonderful. Perl, I’m leaving you.”xkcd