{"id":990053,"date":"2024-12-27T08:16:46","date_gmt":"2024-12-27T00:16:46","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/990053.html"},"modified":"2024-12-27T08:16:50","modified_gmt":"2024-12-27T00:16:50","slug":"python%e5%a6%82%e4%bd%95%e5%ae%89%e8%a3%85pandas%e6%a8%a1%e5%9d%97","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/990053.html","title":{"rendered":"python\u5982\u4f55\u5b89\u88c5pandas\u6a21\u5757"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25064947\/791c6b30-49fb-4b2a-a843-dee5b319fe44.webp\" alt=\"python\u5982\u4f55\u5b89\u88c5pandas\u6a21\u5757\" \/><\/p>\n<p><p> <strong>\u8981\u5728Python\u4e2d\u5b89\u88c5pandas\u6a21\u5757\uff0c\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177pip\uff0c\u6267\u884c\u547d\u4ee4<code>pip install pandas<\/code>\u3001\u901a\u8fc7Anaconda\u8fdb\u884c\u5b89\u88c5\u3001\u786e\u4fddPython\u73af\u5883\u5df2\u8bbe\u7f6e\u597d\u3002<\/strong>\u5176\u4e2d\uff0c\u4f7f\u7528pip\u662f\u6700\u5e38\u89c1\u7684\u65b9\u6cd5\uff0c\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u79cd\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528PIP\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528pip\u5b89\u88c5pandas\u662f\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u4e4b\u4e00\u3002pip\u662fPython\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u80fd\u591f\u4ecePython Package Index (PyPI)\u4e2d\u4e0b\u8f7d\u5e76\u5b89\u88c5\u8f6f\u4ef6\u5305\u3002\u8981\u4f7f\u7528pip\u5b89\u88c5pandas\uff0c\u8bf7\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u68c0\u67e5Python\u548cpip\u662f\u5426\u5b89\u88c5<\/strong><br \/>\u9996\u5148\uff0c\u786e\u4fdd\u60a8\u7684\u7cfb\u7edf\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u548cpip\u3002\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u68c0\u67e5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python --version<\/p>\n<p>pip --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u6ca1\u6709\u5b89\u88c5\uff0c\u8bf7\u5230<a href=\"https:\/\/www.python.org\/\">Python\u5b98\u7f51<\/a>\u4e0b\u8f7d\u5e76\u5b89\u88c5Python\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5pandas<\/strong><br \/>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u5b89\u88c5pandas\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u4ecePyPI\u4e0b\u8f7dpandas\u7684\u6700\u65b0\u7248\u672c\u5e76\u5b89\u88c5\u5230\u60a8\u7684Python\u73af\u5883\u4e2d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong><br \/>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u542f\u52a8Python\u89e3\u91ca\u5668\u5e76\u5bfc\u5165pandas\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>print(pd.__version__)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u6ca1\u6709\u9519\u8bef\u53d1\u751f\u5e76\u663e\u793a\u7248\u672c\u53f7\uff0c\u5219\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u4f7f\u7528Anaconda\u5b89\u88c5<\/h3>\n<\/p>\n<p><p>Anaconda\u662f\u4e00\u4e2a\u6d41\u884c\u7684Python\u53d1\u884c\u7248\uff0c\u7279\u522b\u9002\u7528\u4e8e\u6570\u636e\u79d1\u5b66\u548c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a>\u3002\u5b83\u81ea\u5e26\u4e86\u8bb8\u591a\u5e38\u7528\u7684\u6570\u636e\u79d1\u5b66\u5e93\uff0c\u5305\u62ecpandas\u3002\u4f7f\u7528Anaconda\u5b89\u88c5pandas\u7684\u6b65\u9aa4\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Anaconda<\/strong><br \/>\u5982\u679c\u60a8\u7684\u7cfb\u7edf\u4e2d\u5c1a\u672a\u5b89\u88c5Anaconda\uff0c\u8bf7\u8bbf\u95ee<a href=\"https:\/\/www.anaconda.com\/\">Anaconda\u5b98\u7f51<\/a>\u4e0b\u8f7d\u5e76\u5b89\u88c5\u9002\u5408\u60a8\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u521b\u5efa\u73af\u5883\uff08\u53ef\u9009\uff09<\/strong><br \/>\u4e3a\u4e86\u66f4\u597d\u5730\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56\u5173\u7cfb\uff0c\u5efa\u8bae\u521b\u5efa\u4e00\u4e2a\u65b0\u7684conda\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda create --name myenv python=3.8<\/p>\n<p>conda activate myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5pandas<\/strong><br \/>\u5728\u6fc0\u6d3b\u7684conda\u73af\u5883\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5pandas\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda install pandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u5c06\u4eceAnaconda\u7684\u5305\u7ba1\u7406\u7cfb\u7edf\u4e2d\u4e0b\u8f7d\u5e76\u5b89\u88c5pandas\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong><br \/>\u4e0epip\u5b89\u88c5\u9a8c\u8bc1\u7c7b\u4f3c\uff0c\u542f\u52a8Python\u89e3\u91ca\u5668\uff0c\u5bfc\u5165pandas\u5e76\u68c0\u67e5\u7248\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>print(pd.__version__)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u786e\u4fddPython\u73af\u5883\u5df2\u8bbe\u7f6e\u597d<\/h3>\n<\/p>\n<p><p>\u5728\u5b89\u88c5pandas\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u7684Python\u73af\u5883\u5df2\u7ecf\u6b63\u786e\u8bbe\u7f6e\u3002\u5305\u62ec\u5b89\u88c5\u5408\u9002\u7248\u672c\u7684Python\u3001\u8bbe\u7f6e\u597d\u73af\u5883\u53d8\u91cf\u548c\u66f4\u65b0pip\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u66f4\u65b0pip<\/strong><br \/>\u786e\u4fdd\u60a8\u7684pip\u662f\u6700\u65b0\u7248\u672c\uff0c\u4ee5\u907f\u514d\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u95ee\u9898\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m pip install --upgrade pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff08Windows\u7528\u6237\uff09<\/strong><br \/>\u5728Windows\u7cfb\u7edf\u4e0a\uff0c\u6709\u65f6\u9700\u8981\u624b\u52a8\u6dfb\u52a0Python\u548cpip\u5230\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u76f4\u63a5\u4f7f\u7528<code>python<\/code>\u548c<code>pip<\/code>\u547d\u4ee4\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9\u5408\u9002\u7684Python\u7248\u672c<\/strong><br \/>\u786e\u4fdd\u60a8\u4f7f\u7528\u7684Python\u7248\u672c\u652f\u6301pandas\uff0c\u901a\u5e38\u5efa\u8bae\u4f7f\u7528Python 3.x\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u89e3\u51b3\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u7684\u5e38\u89c1\u95ee\u9898<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\uff0c\u5982\u7f51\u7edc\u8fde\u63a5\u95ee\u9898\u3001\u6743\u9650\u95ee\u9898\u6216\u4f9d\u8d56\u5305\u51b2\u7a81\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u7f51\u7edc\u8fde\u63a5\u95ee\u9898<\/strong><br \/>\u5982\u679c\u4e0b\u8f7d\u901f\u5ea6\u6162\u6216\u8fde\u63a5\u8d85\u65f6\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u66f4\u6362PyPI\u7684\u955c\u50cf\u6e90\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u56fd\u5185\u955c\u50cf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pandas -i https:\/\/pypi.tuna.tsinghua.edu.cn\/simple<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6743\u9650\u95ee\u9898<\/strong><br \/>\u5982\u679c\u9047\u5230\u6743\u9650\u4e0d\u8db3\u7684\u9519\u8bef\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\u7ba1\u7406\u5458\u6743\u9650\u8fd0\u884c\u547d\u4ee4\uff0c\u6216\u8005\u4f7f\u7528<code>--user<\/code>\u6807\u5fd7\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pandas --user<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f9d\u8d56\u5305\u51b2\u7a81<\/strong><br \/>\u5982\u679c\u9047\u5230\u4f9d\u8d56\u5305\u51b2\u7a81\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\u5e76\u5728\u5176\u4e2d\u5b89\u88c5pandas\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u65b9\u6cd5\uff0c\u60a8\u5e94\u8be5\u80fd\u591f\u987a\u5229\u5730\u5728Python\u4e2d\u5b89\u88c5pandas\u6a21\u5757\u3002\u65e0\u8bba\u662f\u4f7f\u7528pip\u8fd8\u662fAnaconda\uff0c\u8fd9\u4e9b\u6b65\u9aa4\u90fd\u80fd\u5e2e\u52a9\u60a8\u5728\u6570\u636e\u5206\u6790\u548c\u79d1\u5b66\u8ba1\u7b97\u4e2d\u5229\u7528pandas\u7684\u5f3a\u5927\u529f\u80fd\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u68c0\u67e5\u6211\u7684Python\u73af\u5883\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u4e86pip\uff1f<\/strong><br \/>\u8981\u786e\u8ba4\u60a8\u7684Python\u73af\u5883\u662f\u5426\u5df2\u5b89\u88c5pip\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u8f93\u5165<code>pip --version<\/code>\u3002\u5982\u679c\u60a8\u770b\u5230pip\u7684\u7248\u672c\u4fe1\u606f\uff0c\u8bf4\u660e\u5df2\u7ecf\u5b89\u88c5\u3002\u5982\u679c\u6ca1\u6709\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u5148\u5b89\u88c5pip\uff0c\u901a\u5e38Python\u7684\u5b98\u65b9\u7f51\u7ad9\u4f1a\u63d0\u4f9b\u76f8\u5173\u6307\u5bfc\u3002<\/p>\n<p><strong>\u5b89\u88c5pandas\u6a21\u5757\u9700\u8981\u6ce8\u610f\u54ea\u4e9b\u4f9d\u8d56\u9879\uff1f<\/strong><br \/>\u5728\u5b89\u88c5pandas\u4e4b\u524d\uff0c\u786e\u4fdd\u60a8\u7684Python\u7248\u672c\u81f3\u5c11\u662f3.6\u4ee5\u4e0a\uff0c\u5e76\u4e14\u7cfb\u7edf\u4e2d\u5df2\u7ecf\u5b89\u88c5\u4e86numpy\u6a21\u5757\uff0c\u56e0\u4e3apandas\u662f\u5efa\u7acb\u5728numpy\u4e4b\u4e0a\u7684\u3002\u5b89\u88c5pandas\u65f6\uff0cpip\u4f1a\u81ea\u52a8\u5904\u7406\u8fd9\u4e9b\u4f9d\u8d56\u9879\uff0c\u4f46\u786e\u8ba4numpy\u5df2\u7ecf\u5b58\u5728\u80fd\u591f\u907f\u514d\u6f5c\u5728\u7684\u5b89\u88c5\u95ee\u9898\u3002<\/p>\n<p><strong>\u6211\u53ef\u4ee5\u901a\u8fc7\u54ea\u4e9b\u65b9\u5f0f\u5b89\u88c5pandas\u6a21\u5757\uff1f<\/strong><br \/>pandas\u6a21\u5757\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5b89\u88c5\u3002\u6700\u5e38\u89c1\u7684\u662f\u4f7f\u7528pip\uff0c\u60a8\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u8f93\u5165<code>pip install pandas<\/code>\u3002\u53e6\u5916\uff0c\u60a8\u4e5f\u53ef\u4ee5\u901a\u8fc7Anaconda\u5b89\u88c5\uff0c\u4f7f\u7528\u547d\u4ee4<code>conda install pandas<\/code>\uff0c\u8fd9\u5bf9\u4e8e\u6570\u636e\u79d1\u5b66\u548c\u673a\u5668\u5b66\u4e60\u7684\u5de5\u4f5c\u6d41\u7a0b\u7279\u522b\u65b9\u4fbf\uff0c\u56e0\u4e3aAnaconda\u4f1a\u81ea\u52a8\u5904\u7406\u5404\u79cd\u5e93\u4e4b\u95f4\u7684\u517c\u5bb9\u6027\u95ee\u9898\u3002<\/p>\n<p><strong>\u5982\u679c\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u9519\u8bef\uff0c\u6211\u8be5\u5982\u4f55\u89e3\u51b3\uff1f<\/strong><br \/>\u5728\u5b89\u88c5pandas\u65f6\uff0c\u5982\u679c\u9047\u5230\u9519\u8bef\u4fe1\u606f\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u51e0\u4e2a\u89e3\u51b3\u65b9\u6848\u3002\u9996\u5148\uff0c\u786e\u4fdd\u60a8\u7684pip\u662f\u6700\u65b0\u7248\u672c\uff0c\u53ef\u4ee5\u901a\u8fc7<code>pip install --upgrade pip<\/code>\u6765\u66f4\u65b0\u3002\u5176\u6b21\uff0c\u68c0\u67e5\u7f51\u7edc\u8fde\u63a5\uff0c\u56e0\u4e3apip\u9700\u8981\u4ece\u7f51\u7edc\u4e0a\u4e0b\u8f7d\u5305\u3002\u5982\u679c\u9519\u8bef\u4f9d\u7136\u5b58\u5728\uff0c\u53ef\u4ee5\u641c\u7d22\u9519\u8bef\u4fe1\u606f\uff0c\u901a\u5e38\u4f1a\u627e\u5230\u76f8\u5173\u7684\u89e3\u51b3\u65b9\u6848\u6216\u793e\u533a\u8ba8\u8bba\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5728Python\u4e2d\u5b89\u88c5pandas\u6a21\u5757\uff0c\u53ef\u4ee5\u4f7f\u7528\u5305\u7ba1\u7406\u5de5\u5177pip\uff0c\u6267\u884c\u547d\u4ee4pip install pandas [&hellip;]","protected":false},"author":3,"featured_media":990062,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/990053"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=990053"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/990053\/revisions"}],"predecessor-version":[{"id":990065,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/990053\/revisions\/990065"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/990062"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=990053"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=990053"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=990053"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}