You can upgrade Pandas to the latest version or to a specific version in several ways on Windows or Linux depending on how you want to update. You can either use the pip install
command to upgrade the version of the Python package (in this case pandas) or if you are using conda you can use conda install
to upgrade Pandas.
Note: If you already have a Pandas version installed and you getting errors while upgrading to a higher version, sometimes uninstalling the existing version may resolve the issue. you can use sudo pip uninstall pandas
to uninstall on a Linux server. Install the latest Pandas version on Windows if you don’t have it.
Key Points –
- The most common method to upgrade Pandas is via the Python package manager
pip
using the commandpip install --upgrade pandas
. - If you’re using Anaconda or Miniconda, Pandas can be upgraded using
conda update pandas
. - You can upgrade to a specific version of Pandas using
pip install pandas==x.y.z
orconda install pandas=x.y.z
, wherex.y.z
is the desired version. - Before upgrading, you can check the current version of Pandas using
pip show pandas
orimport pandas as pd; print(pd.__version__)
. - When upgrading with
pip
, you can use the--no-cache-dir
flag to force the installation of the latest version and avoid using any cached versions. - If an upgrade introduces issues, you can roll back to a previous version using
pip install pandas==previous_version
orconda install pandas=previous_version
.
Related: Using PIP to Upgrade itself to Latest or Specific Version
Upgrade Pandas to Latest Version Using Pip
If you are using pip, you can upgrade Pandas to the latest version by issuing the below command. If you are not aware, PIP is a package management system used to install and manage software packages written in Python. Before upgrading the version it’s always a best practice to check the pandas version installed on your system.
You can run this pip command either from the Linux shell, Windows command tool, or from the Anaconda command prompt to upgrade Python packages.
Note: On Windows make sure you have administrator access in order to run this command. On Linux make sure you have sudo
access to root.
# Using pip3 to upgrade pandas
pip3 install --upgrade pandas
# Alternatively you can also try
python -m pip install --upgrade pandas
If you don’t have PATH setup for python/pip, you will get an error; so make sure you have PATH set-up on Linux and on Windows to run pip commands.
The above command upgraded my Pandas version to 1.3.1 on my laptop which is the latest version at the time of writing this article.
On Linux, if you get an access issue, run by adding sudo
to suffix like sudo pip3 install --upgrade pandas
.
Upgrade Pandas to Specific Version
In case, if you do not want the latest version instead you want to upgrade to a specific version, you can do this using the below command. If you are eventually planning to upgrade the production system to a specific version, make sure the version you are upgrading doesn’t have any security issues and is stable.
# Upgrade to specific version
pip install pandas==specific-higher-version
Check Pandas Version From the Command Line
By using the below command you can check the Pandas upgraded version from the command line.
# List all packages
pip3 list
As you see above list, Pandas has upgraded to the 1.3.1 version.
Upgrade Pandas Version using Conda (Anaconda)
If you are using Anaconda distribution, you can use conda install
to upgrade Pandas to the latest version.
# Using conda install
conda install -c anaconda pandas
Alternatively, you can also upgrade using conda update
command.
# Use conda update
conda update pandas
To upgrade Pandas to a specific version
# Upgrade to specific version of pandas
conda update pandas==0.14.0
FAQ on Upgrade Pandas Version to Latest or Specific Version
How do I upgrade Pandas to the latest version?
To upgrade Pandas to the latest version, you can use the pip install --upgrade pandas
command.
If you want to install a specific version of Pandas, you can use the pip install pandas==<desired_version>
command. Replace <desired_version>
with the version number you want to install. For example, to install Pandas version 1.2.3 pip install pandas==1.2.3
You can check your current Pandas version by running the following command in a Python environment. For example, print(pd.__version__)
You can upgrade Pandas from a Jupyter Notebook. Simply open a new cell and run the !pip install --upgrade pandas
command
Conclusion
In this article, you have learned how to upgrade to the latest version or to a specific version using pip and conda commands. Note that to install Pandas, you may need access to Windows administration or Unix sudo to root access.
Happy Learning !!
Related Articles
- How to use Series with Examples.
- Remove NaN From Pandas Series
- Pandas Convert Column to String Type?
- Pandas Shuffle DataFrame Rows Examples
- Pandas Operator Chaining to Filter DataFrame Rows
- Different Ways to Rename Pandas DataFrame Column Names
- How to transform or remap Pandas DataFrame column values with Dict