How to Check Pandas Version?

  • Post author:
  • Post category:Pandas
  • Post last modified:October 5, 2023

One can check pandas version on the Linux server, Windows system, and Mac OS by running pip commands either from the command line or by running a statement from a Python program. You can pretty much run these commands on any system where the pip package is installed.

In this article, I will covert getting pandas package version by using shell command or from programmatically. Install the latest pandas version on windows if you don’t have it.

1. Check pandas Version from Command or Shell mode

From a command line or shell run the pip list command to check the pandas version or get the list of the package installed with the currently installed version next to the package. If you don’t have pandas installed then this command doesn’t list it. I have a pip3 installed so I am using pip3 to find out the pandas version installed.

Check Pandas Version

My installed version of pandas is 1.3.1 hence it shows on the list.

2. Check pandas Version from Programatically

Sometimes you may need to know the pandas version programmatically at runtime in order to make a decision and take different paths based on the version installed.

In order to check the pandas version programmatically, first, you need to import pandas and use pd.__version__ attribute.


import pandas as pd
 
# Get pandas Version
print(pd.__version__)

3. Find All pandas Version and it’s Dependency Package Versions

Pandas package has a lot of other package dependencies and you can get these by running the pd.show_version() method of pandas.


import pandas as pd
  
# Shows the version of the Pandas dependencies
print(pd.show_versions())

This returns a list of pandas dependencies and their versions.

Get Pandas Version Dependencies

4. Other Alternate Ways to Get Current Installed Version

Below are other alternative ways to get version from windows command and Linux shell/Mac OS terminal. In order to use conda you need to have Anaconda distribution installed on your system.

On Windows


# By using Python
python -c "import pandas as pd; print(pd.__version__)"

# By using Anaconda utility Conda
conda list | findstr pandas

# By using pip
pip freeze | findstr pandas
pip show pandas | findstr Version

On Linux/Mac OS: You can use these on Linux or Mac OS to find Version.


# By using Python
python -c "import pandas as pd; print(pd.__version__)"

# By using Anaconda utility Conda
conda list | grep numpy 

# By using pip
pip freeze | grep numpy

Conclusion

Here you have learned different ways to get or find pandas installed versions. You can use these on Linux, Windows, Mac, or any other OS that supports Python, pip, and Anaconda. You have also learned to get the version programmatically using __version__ attribute and show_versions() method.

Happy Learning !!

References

Naveen

I am a Data Engineer with 20+ years of experience in transforming data into actionable insights. Over the years, I have honed my expertise in designing, implementing, and maintaining data pipelines with frameworks like Apache Spark, PySpark, Pandas, R, Hive and Machine Learning. My journey in the field of data engineering has been a continuous learning, innovation, and a strong commitment to data integrity. I have started this SparkByExamples.com to share my experiences with the data as I come across. You can learn more about me at LinkedIn

Leave a Reply

You are currently viewing How to Check Pandas Version?