How to check the pandas version in Python
Before working with pandas, we must ensure the correct version is installed on our system. We can check if the correct pandas version is installed using the following ways.
Use the
pip showcommandUse the
__version__attribute
Method 1: Use the pip show command
Let's look at how to check the currently installed version of pandas using the pip show command.
Install the pandas library using the
pip3 install pandascommand.Use the
pip show pandascommand to get information about the pandas package, including the version.
Method 2: Use the __version__ attribute
Let's look at how to check the currently installed version of pandas using the __version__ attribute.
As we have already installed the pandas, we now execute the
python3command to enter the Python environment.Import the pandas library using the
import pandas as pdcommand.Print the
__version__attribute of the pandas using theprint(pd.__version__)command to check the currently installed version of pandas.Execute the
exit()command to exit the Python environment.
Playground
Run any of the methods listed above in the terminal below to check the installed pandas version.
Note: We have already installed Python in the terminal below. Execute the command
python3 --versionto check the Python version.
Conclusion
We have discussed two methods to check the pandas version. Using any of these methods, we can easily check and ensure that we have installed the system's correct version of the pandas.
Free Resources