How to Install Pandas Specific Version - With Pip and Anaconda

How to Install Pandas Specific Version - With Pip and Anaconda

How to Install Pandas Specific Version

To install a specific version of Pandas, you have 2 options, depending on how Python is installed on your system:

  • Pip: Run pip install pandas==<version>
  • Anaconda: Run conda install pandas=<version>

Note how Anaconda uses one equal sign, while Pip uses two.

The rest of the article will walk you through how to install Pandas specific version, for those of you who don’t want to stick with the default one. It’s assumed you already have Python installed.


How to Install a Specific Version of Pandas with Pip

At the moment (March 2023), the latest stable version of Pandas is 1.5.3. There’s a major 2.0 update coming soon, and maybe you want to take it for a test ride.

Installing Pandas normally, without specifying the version will install the latest stable release. To install the RC1 version of Pandas 2.0, run the following shell command:

pip install pandas==2.0.0rc1
Image 1 - Installing Pandas 2.0 with Pip (Image by author)

Image 1 - Installing Pandas 2.0 with Pip (Image by author)

You can now open the Python shell to verify the correct Pandas version was installed on your system:

Image 2 - Testing Pandas specific version installation (Image by author)

Image 2 - Testing Pandas specific version installation (Image by author)

It looks like you have version 2.0.0, which is just what we wanted! You can repeat this process to install any version of Pandas, provided there’s no collision with your current Python version.


How to Install Specific Version of Pandas with Anaconda

Now, Anaconda doesn’t have the best track record of keeping up with the most recent package development releases. In short, good luck finding the development version of Pandas 2.0 through Conda.

That’s why we’ll install a somewhat older Pandas version - 1.3.4. Keep in mind that version specification in Anaconda uses only a single equal sign, unlike Pip.

Run the following command to install Pandas specific version with Anaconda:

conda install pandas=1.3.4
Image 3 - Installing Pandas 1.3.4 with Anaconda (Image by author)

Image 3 - Installing Pandas 1.3.4 with Anaconda (Image by author)

And now open up the Python shell, import Pandas, and print its version:

Image 4 - Testing Pandas specific version installation (Image by author)

Image 4 - Testing Pandas specific version installation (Image by author)

It looks like the correct version was installed, so we can mark our job here as done.


Summing up

You probably don’t want to install a deprecated version of the library on your system, at least not when working on new products, so what’s the point of this article? Well, maybe you’re planning on deploying your project and need a requirements.txt file. These typically have the library name followed by a version, since you don’t want a recent package update to break something in your production code.

Or maybe you just want to install the most recent development version inside a virtual environment. That’s likely the case with Pandas 2.0 since there are major changes when compared to the previous releases.

Whatever the case might be, you now know how to take full control of your Pandas version.