Javascript required
Skip to content Skip to sidebar Skip to footer

How to Check if Pandas Is Installed in Python

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, 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 print(pd.__version__)

The output in my Python script is:

1.0.1

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 Home-page: https://pandas.pydata.org 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 print(pd.show_versions())

And the output:

INSTALLED VERSIONS ------------------ commit           : None python           : 3.7.2.final.0 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: https://pandas.pydata.org/docs/whatsnew/index.html

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

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

How to Check if Pandas Is Installed in Python

Source: https://blog.finxter.com/how-to-check-the-pandas-version-in-your-script/