{"id":987052,"date":"2024-12-27T07:50:12","date_gmt":"2024-12-26T23:50:12","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/987052.html"},"modified":"2024-12-27T07:50:14","modified_gmt":"2024-12-26T23:50:14","slug":"python%e4%b8%ad%e5%a6%82%e4%bd%95%e5%ae%89%e8%a3%85pandas-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/987052.html","title":{"rendered":"python\u4e2d\u5982\u4f55\u5b89\u88c5pandas"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25063340\/e92432cd-1d22-4790-8ab9-f4aeaa322266.webp\" alt=\"python\u4e2d\u5982\u4f55\u5b89\u88c5pandas\" \/><\/p>\n<p><p> \u5728Python\u4e2d\uff0c\u5b89\u88c5Pandas\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5b9e\u73b0\uff0c\u4e3b\u8981\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528pip\u547d\u4ee4\u3001\u4f7f\u7528Anaconda\u5305\u7ba1\u7406\u5668\u3001\u4ee5\u53ca\u4ece\u6e90\u4ee3\u7801\u5b89\u88c5\u3002<strong>\u4f7f\u7528pip\u547d\u4ee4\u3001\u4f7f\u7528Anaconda\u5305\u7ba1\u7406\u5668\u3001\u4ece\u6e90\u4ee3\u7801\u5b89\u88c5<\/strong>\u662f\u6700\u5e38\u89c1\u7684\u65b9\u6cd5\u3002\u63a8\u8350\u4f7f\u7528pip\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff0c\u56e0\u4e3a\u5b83\u662fPython\u7684\u6807\u51c6\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u9002\u7528\u4e8e\u5927\u591a\u6570\u573a\u666f\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7\u8fd9\u51e0\u79cd\u65b9\u6cd5\u6765\u5b89\u88c5Pandas\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528PIP\u547d\u4ee4\u5b89\u88c5<\/p>\n<\/p>\n<p><p>Pip\u662fPython\u7684\u5305\u7ba1\u7406\u7cfb\u7edf\uff0c\u5141\u8bb8\u7528\u6237\u5b89\u88c5\u548c\u7ba1\u7406Python\u5305\u3002Pandas\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u7b80\u5355\u7684pip\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol>\n<li>\n<p><strong>\u786e\u4fdd\u5df2\u5b89\u88c5Python\u548cPip<\/strong>\uff1a\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u7684\u7cfb\u7edf\u4e0a\u5df2\u5b89\u88c5Python\u548cPip\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\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\u672a\u5b89\u88c5\uff0c\u53ef\u4ee5\u4ecePython\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5Python\u3002Pip\u901a\u5e38\u4f1a\u968fPython\u4e00\u8d77\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528pip\u5b89\u88c5Pandas<\/strong>\uff1a\u6253\u5f00\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\uff0c\u5e76\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\u4ecePython\u5305\u7d22\u5f15\uff08PyPI\uff09\u4e0b\u8f7d\u5e76\u5b89\u88c5Pandas\u53ca\u5176\u6240\u6709\u4f9d\u8d56\u9879\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7Python\u89e3\u91ca\u5668\u9a8c\u8bc1Pandas\u662f\u5426\u5df2\u6b63\u786e\u5b89\u88c5\u3002\u542f\u52a8Python\uff0c\u5e76\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\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\u6d88\u606f\uff0c\u5e76\u4e14\u8f93\u51fa\u4e86Pandas\u7684\u7248\u672c\u53f7\uff0c\u5219\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u4f7f\u7528ANACONDA\u5305\u7ba1\u7406\u5668\u5b89\u88c5<\/p>\n<\/p>\n<p><p>Anaconda\u662f\u4e00\u4e2a\u6d41\u884c\u7684\u6570\u636e\u79d1\u5b66\u5e73\u53f0\uff0c\u5305\u542b\u4e86Python\u548c\u8bb8\u591a\u6709\u7528\u7684\u5e93\uff0c\u5305\u62ecPandas\u3002\u5b83\u4f7f\u7528Conda\u4f5c\u4e3a\u5305\u7ba1\u7406\u5668\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Anaconda<\/strong>\uff1a\u9996\u5148\uff0c\u4eceAnaconda\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5Anaconda\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528Conda\u5b89\u88c5Pandas<\/strong>\uff1a\u6253\u5f00Anaconda Prompt\uff08Windows\uff09\u6216\u7ec8\u7aef\uff08MacOS\/Linux\uff09\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\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\u4f7f\u7528Conda\u5305\u7ba1\u7406\u5668\u5b89\u88c5Pandas\u53ca\u5176\u6240\u6709\u4f9d\u8d56\u9879\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a\u4e0epip\u7c7b\u4f3c\uff0c\u53ef\u4ee5\u901a\u8fc7Python\u89e3\u91ca\u5668\u9a8c\u8bc1Pandas\u7684\u5b89\u88c5\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>\u8f93\u51fa\u7248\u672c\u53f7\u8868\u793a\u6210\u529f\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u4ece\u6e90\u4ee3\u7801\u5b89\u88c5<\/p>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u5e0c\u671b\u4ece\u6e90\u4ee3\u7801\u5b89\u88c5Pandas\u3002\u8fd9\u901a\u5e38\u7528\u4e8e\u5f00\u53d1\u76ee\u7684\uff0c\u6216\u8005\u5f53\u9700\u8981\u5b89\u88c5\u5c1a\u672a\u53d1\u5e03\u7684\u7279\u6027\u6216\u4fee\u590d\u65f6\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u514b\u9686Pandas\u4ed3\u5e93<\/strong>\uff1a\u9996\u5148\uff0c\u514b\u9686Pandas\u7684GitHub\u4ed3\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">git clone https:\/\/github.com\/pandas-dev\/pandas.git<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u4f9d\u8d56\u9879<\/strong>\uff1a\u786e\u4fdd\u5b89\u88c5\u4e86\u6784\u5efaPandas\u6240\u9700\u7684\u6240\u6709\u4f9d\u8d56\u9879\u3002\u60a8\u53ef\u4ee5\u67e5\u770b<code>requirements-dev.txt<\/code>\u6587\u4ef6\u4ee5\u83b7\u53d6\u4f9d\u8d56\u9879\u5217\u8868\uff0c\u5e76\u4f7f\u7528pip\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install -r requirements-dev.txt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6784\u5efa\u5e76\u5b89\u88c5Pandas<\/strong>\uff1a\u8fdb\u5165Pandas\u76ee\u5f55\uff0c\u5e76\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python setup.py build<\/p>\n<p>python setup.py install<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a\u4e0e\u524d\u9762\u7684\u6b65\u9aa4\u7c7b\u4f3c\uff0c\u901a\u8fc7Python\u89e3\u91ca\u5668\u9a8c\u8bc1\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u5b89\u88c5\u6ce8\u610f\u4e8b\u9879<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u865a\u62df\u73af\u5883<\/strong>\uff1a\u5efa\u8bae\u5728\u865a\u62df\u73af\u5883\u4e2d\u5b89\u88c5Pandas\uff0c\u4ee5\u907f\u514d\u4e0e\u5176\u4ed6\u9879\u76ee\u7684\u4f9d\u8d56\u51b2\u7a81\u3002\u53ef\u4ee5\u4f7f\u7528<code>venv<\/code>\u6a21\u5757\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m venv myenv<\/p>\n<p>source myenv\/bin\/activate  # \u5728Linux\u6216MacOS\u4e0a<\/p>\n<p>myenv\\Scripts\\activate     # \u5728Windows\u4e0a<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\u5728\u6fc0\u6d3b\u7684\u865a\u62df\u73af\u5883\u4e2d\u4f7f\u7528pip\u5b89\u88c5Pandas\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9\u6b63\u786e\u7684Python\u7248\u672c<\/strong>\uff1aPandas\u652f\u6301Python 3.6\u53ca\u4ee5\u4e0a\u7248\u672c\u3002\u56e0\u6b64\uff0c\u8bf7\u786e\u4fdd\u60a8\u4f7f\u7528\u7684\u662f\u53d7\u652f\u6301\u7684Python\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u89e3\u51b3\u5b89\u88c5\u95ee\u9898<\/strong>\uff1a\u5982\u679c\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9047\u5230\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p>\u68c0\u67e5\u7f51\u7edc\u8fde\u63a5\uff0c\u786e\u4fdd\u80fd\u591f\u8bbf\u95eePyPI\u6216Conda\u670d\u52a1\u5668\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528<code>--upgrade<\/code>\u9009\u9879\u66f4\u65b0pip\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install --upgrade pip<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u68c0\u67e5\u9519\u8bef\u6d88\u606f\uff0c\u786e\u4fdd\u6ee1\u8db3\u6240\u6709\u4f9d\u8d56\u9879\u7684\u8981\u6c42\u3002<\/p>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u5347\u7ea7\u548c\u5378\u8f7dPandas<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5347\u7ea7Pandas<\/strong>\uff1a\u8981\u5347\u7ea7\u5230\u6700\u65b0\u7248\u672c\u7684Pandas\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install --upgrade pandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\u4f7f\u7528Conda\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda update pandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5378\u8f7dPandas<\/strong>\uff1a\u5982\u679c\u9700\u8981\u5378\u8f7dPandas\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip uninstall pandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6216\u8005\u4f7f\u7528Conda\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda remove pandas<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u603b\u4e4b\uff0c\u5b89\u88c5Pandas\u5728Python\u4e2d\u662f\u4e00\u4e2a\u76f8\u5bf9\u7b80\u5355\u7684\u8fc7\u7a0b\u3002\u901a\u8fc7pip\u6216Conda\uff0c\u53ef\u4ee5\u5feb\u901f\u5b89\u88c5\u548c\u7ba1\u7406Pandas\u5e93\u3002\u9009\u62e9\u9002\u5408\u81ea\u5df1\u9700\u6c42\u7684\u65b9\u6cd5\uff0c\u5e76\u6ce8\u610f\u5728\u865a\u62df\u73af\u5883\u4e2d\u64cd\u4f5c\uff0c\u4ee5\u83b7\u5f97\u6700\u4f73\u7684\u5f00\u53d1\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5b89\u88c5pandas\u5e93\uff1f<\/strong><br \/>\u5728Python\u4e2d\u5b89\u88c5pandas\u5e93\u901a\u5e38\u4f7f\u7528pip\u8fd9\u4e00\u5305\u7ba1\u7406\u5de5\u5177\u3002\u4f60\u53ef\u4ee5\u5728\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<code>pip install pandas<\/code>\u3002\u786e\u4fdd\u4f60\u7684Python\u73af\u5883\u5df2\u7ecf\u6b63\u786e\u914d\u7f6e\uff0c\u5e76\u4e14pip\u5df2\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\uff0c\u4ee5\u907f\u514d\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u51fa\u73b0\u7684\u9519\u8bef\u3002<\/p>\n<p><strong>\u5982\u679c\u5728\u5b89\u88c5pandas\u65f6\u9047\u5230\u9519\u8bef\uff0c\u5e94\u8be5\u600e\u4e48\u529e\uff1f<\/strong><br \/>\u9047\u5230\u5b89\u88c5\u9519\u8bef\u65f6\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u51e0\u4e2a\u6b65\u9aa4\u3002\u9996\u5148\uff0c\u786e\u8ba4\u4f60\u7684pip\u7248\u672c\u662f\u6700\u65b0\u7684\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4<code>pip install --upgrade pip<\/code>\u8fdb\u884c\u66f4\u65b0\u3002\u5982\u679c\u4f9d\u7136\u65e0\u6cd5\u5b89\u88c5\uff0c\u8003\u8651\u67e5\u770b\u9519\u8bef\u4fe1\u606f\uff0c\u53ef\u80fd\u662f\u7f3a\u5c11\u67d0\u4e9b\u4f9d\u8d56\u5e93\uff0c\u6309\u63d0\u793a\u5b89\u88c5\u8fd9\u4e9b\u4f9d\u8d56\u540e\u518d\u5c1d\u8bd5\u5b89\u88c5pandas\u3002<\/p>\n<p><strong>\u5b89\u88c5pandas\u540e\uff0c\u5982\u4f55\u786e\u8ba4\u5b83\u662f\u5426\u6210\u529f\uff1f<\/strong><br \/>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7Python\u4ea4\u4e92\u5f0f\u547d\u4ee4\u884c\u6216IDE\uff08\u5982Jupyter Notebook\uff09\u6765\u9a8c\u8bc1pandas\u662f\u5426\u6210\u529f\u5b89\u88c5\u3002\u8f93\u5165<code>import pandas as pd<\/code>\uff0c\u5982\u679c\u6ca1\u6709\u4efb\u4f55\u9519\u8bef\u63d0\u793a\uff0c\u8868\u660e\u5b89\u88c5\u6210\u529f\u3002\u63a5\u4e0b\u6765\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528<code>pd.__version__<\/code>\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u5b89\u88c5\u7684pandas\u7248\u672c\uff0c\u4ee5\u786e\u4fdd\u5176\u4e3a\u4f60\u6240\u9700\u7684\u7248\u672c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\uff0c\u5b89\u88c5Pandas\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5b9e\u73b0\uff0c\u4e3b\u8981\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528pip\u547d\u4ee4\u3001\u4f7f\u7528Anaconda\u5305\u7ba1 [&hellip;]","protected":false},"author":3,"featured_media":987055,"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\/987052"}],"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=987052"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/987052\/revisions"}],"predecessor-version":[{"id":987057,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/987052\/revisions\/987057"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/987055"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=987052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=987052"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=987052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}