How do I check the versions of Python modules?
You can use the built-in "pkg_resources" module to check the version of a Python module. Here is a code snippet that shows how to check the version of the "pandas" module:
import pkg_resources
module_name = "pandas"
module_version = pkg_resources.get_distribution(module_name).version
print(f"{module_name} version: {module_version}")
This code snippet imports the "pkg_resources" module, assigns the name of the module you want to check (in this case, "pandas") to a variable, and then uses the "get_distribution" method to retrieve the version of the module. The version is then printed to the console.
You can also use pip package manager to check version of any module as well.
!pip show pandas
This will show the version of pandas module installed on your machine.