How to install pandas in Python?


Pandas is a powerful Python data analysis toolkit. It’s popular for its ease of use, rich feature set, and active development community. In this blog post, we’ll show you how to install pandas in Python on Windows, macOS, and Linux.

Windows

To install pandas on Windows, you can use the pip package manager that comes with Python. To do so, open a Command Prompt window and type the following command:

pip install pandas

Once the installation is complete, you can verify it by opening a Python shell and importing the pandas module:

import pandas as pd
Code language: JavaScript (javascript)

If no errors occur, then Pandas was installed successfully.

macOS

To install pandas on macOS, you can use the Homebrew package manager. If you don’t already have Homebrew installed, follow these instructions to do so. After Homebrew is installed, you can install Pandas with the following command:

brew install pandas

Once the installation is complete, you can verify it by opening a Python shell and importing the pandas module:

import pandas as pd
Code language: JavaScript (javascript)

If no errors occur, then Pandas was installed successfully.

Linux

To install pandas on Linux, you can use the apt package manager that comes with most distributions of Linux.

To do so, open a Terminal window and type the following command:

sudo apt-get install python-pandas
Code language: JavaScript (javascript)

Once the installation is complete, you can verify it by opening a Python shell and importing the pandas module:

import pandas as pd
Code language: JavaScript (javascript)

If no errors occur, then Pandas was installed successfully.

How to check the version of pandas?

Checking the version of pandas used in the python script by:

Get the version number:

__version__ attribute

Show detailed information such as dependent packages: You use show_versions() Function.

Get the pandas version

import pandas as pd print(pd.__version__) # Output: 1.5.0
Code language: CSS (css)

Show detailed information, such as which packages depend on others: The function show versions()

In the pandas.show versions() function, detailed information is shown, such as the version of Python, the packages that depend on it, the type of operating system, etc.

import pandas as pd pd.show_versions()
Code language: Python (python)

Output:

INSTALLED VERSIONS ------------------ commit : 87cfe4e38bafe7300a6003a1d18bd80f3f77c763 python : 3.10.7.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.25211 machine : AMD64 processor : Intel64 Family 6 Model 165 Stepping 3, GenuineIntel byteorder : little LC_ALL : None LANG : None LOCALE : English_United States.1252 pandas : 1.5.0 numpy : 1.23.3 pytz : 2022.4 dateutil : 2.8.2 setuptools : 63.2.0 pip : 22.2.2 Cython : None pytest : None hypothesis : None sphinx : None
Code language: CSS (css)

Conclusion

In this blog post, we showed you how to install Pandas in Python on Windows, macOS, and Linux. We also showed you how to verify that the installation was successful.

Now that you know how to install Pandas, head over to our tutorial on How to Use Pandas to get started using this powerful data analysis toolkit.

Andy Avery

I really enjoy helping people with their tech problems to make life easier, ​and that’s what I’ve been doing professionally for the past decade.

Recent Posts