How to check the version of Pandas

When using panda for data processing, some functions may be obsolete in some versions. To solve this problem, you need to know the version number in the current environment. How to check the version number of pandas?

Use version Variable

In pandas, there is a version variable that directly records the current version number.

Run the following code and output the version number. In my environment, the version of pandas is: 0.24.2

1
2
3
import pandas as pd

print (pd.__version__)

Use show_versions function

The show_versions function in pandas can display the version numbers of pandas and related dependent libraries. The code is as follows:

1
2
3
import pandas as pd

print (pd.show_versions())

Will output something similar to the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
INSTALLED VERSIONS
------------------
commit: None
python: 3.7.3.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: zh_CN.UTF-8
LOCALE: None.None

pandas: 0.24.2
pytest: 4.3.1
pip: 19.0.3
setuptools: 40.8.0
Cython: 0.29.6
numpy: 1.16.2
scipy: 1.2.1
pyarrow: None
xarray: None
IPython: 7.4.0
sphinx: 1.8.5
patsy: 0.5.1
dateutil: 2.8.0
pytz: 2018.9
blosc: None
bottleneck: 1.2.1
tables: 3.5.1
numexpr: 2.6.9
feather: None
matplotlib: 3.0.3
openpyxl: 2.6.1
xlrd: 1.2.0
xlwt: 1.3.0
xlsxwriter: 1.1.5
lxml.etree: 4.3.2
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

Use pip list

If you use pip as a package management tool, you can also use the pip list command, which will output the names and version numbers of all packages in the current environment.

Of course, if you are using a Unix-like system, you can also use grep to control the output for easy viewing, such as:

1
2
pip list | grep pandas
pandas 0.24.2

本文标题:How to check the version of Pandas

文章作者:Morning Star

发布时间:2021年07月05日 - 05:07

最后更新:2022年01月03日 - 11:01

原始链接:https://www.mls-tech.info/python/python-pandas-version_en/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。