{"id":492158,"date":"2024-07-10T08:51:52","date_gmt":"2024-07-10T07:51:52","guid":{"rendered":"https:\/\/blog.jetbrains.com\/pycharm\/2024\/07\/polars-vs-pandas\/"},"modified":"2024-07-18T04:51:21","modified_gmt":"2024-07-18T03:51:21","slug":"polars-vs-pandas","status":"publish","type":"pycharm","link":"https:\/\/blog.jetbrains.com\/zh-hans\/pycharm\/2024\/07\/polars-vs-pandas\/","title":{"rendered":"Polars \u4e0e pandas\uff1a\u5dee\u5f02\u5bf9\u6bd4"},"content":{"rendered":"\n<p>\u5982\u679c\u60a8\u6709\u5173\u6ce8\u8fc7\u53bb\u4e00\u5e74\u4e2d Python DataFrame \u7684\u8fdb\u5c55\uff0c\u90a3\u4e48\u60a8\u4e00\u5b9a\u542c\u8bf4\u8fc7&nbsp;<a href=\"https:\/\/www.pola.rs\/\" target=\"_blank\" rel=\"noreferrer noopener\">Polars<\/a>\uff0c\u4e13\u4e3a\u5904\u7406\u5927\u578b\u6570\u636e\u96c6\u800c\u8bbe\u8ba1\u7684\u5f3a\u5927 DataFrame \u5e93\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"2560\" height=\"1440\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/08\/Preview-page-1280x720-2x-1.jpg\" alt=\"\" class=\"wp-image-384206\"\/><\/figure>\n\n\n\n<p>\u4e0e&nbsp;<a href=\"https:\/\/spark.apache.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Spark<\/a>\u3001<a href=\"https:\/\/www.dask.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Dask<\/a>&nbsp;\u548c&nbsp;<a href=\"https:\/\/www.ray.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">Ray<\/a>&nbsp;\u7b49\u5904\u7406\u5927\u578b\u6570\u636e\u96c6\u7684\u5176\u4ed6\u5e93\u6709\u6240\u4e0d\u540c\uff0cPolars \u5728\u5355\u53f0\u673a\u5668\u4e0a\u4f7f\u7528\uff0c\u4e5f\u56e0\u6b64\u5f15\u8d77\u8bb8\u591a\u4e0e&nbsp;<a href=\"https:\/\/pandas.pydata.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">pandas<\/a>&nbsp;\u7684\u6bd4\u8f83\u3002 \u4e8b\u5b9e\u4e0a\uff0cPolars \u5728\u8bb8\u591a\u91cd\u8981\u65b9\u9762\u90fd\u4e0e pandas \u5b58\u5728\u5dee\u5f02\uff0c\u5305\u62ec\u6570\u636e\u5904\u7406\u65b9\u5f0f\u4ee5\u53ca\u6700\u4f73\u5e94\u7528\u3002 \u4e0b\u6587\u5c06\u63a2\u8ba8\u8fd9\u4e24\u79cd DataFrame \u5e93\u7684\u6280\u672f\u7ec6\u8282\u533a\u522b\uff0c\u5e76\u5206\u6790\u5176\u5404\u81ea\u4f18\u70b9\u548c\u5c40\u9650\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u60a8\u60f3\u542c Polars \u7684\u7f14\u9020\u8005&nbsp;<a href=\"https:\/\/github.com\/ritchie46\" target=\"_blank\" rel=\"noreferrer noopener\">Ritchie Vink<\/a>&nbsp;\u4eb2\u53e3\u8bb2\u8ff0\uff0c\u60a8\u53ef\u4ee5\u5728<a href=\"https:\/\/www.youtube.com\/watch?v=QfLzEp-yt_U\" target=\"_blank\" rel=\"noreferrer noopener\">\u6b64\u5904<\/a>\u627e\u5230\u6211\u4eec\u5bf9\u4ed6\u7684\u91c7\u8bbf\uff01<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u4e3a\u4ec0\u4e48\u4f7f\u7528-polars-\u800c\u4e0d\u662f-pandas\uff1f\">\u4e3a\u4ec0\u4e48\u4f7f\u7528 Polars \u800c\u4e0d\u662f pandas\uff1f<\/h2>\n\n\n\n<p>\u4e24\u4e2a\u5b57\uff1a\u6027\u80fd\u3002 Polars \u4ece\u4e00\u5f00\u59cb\u5c31\u901f\u5ea6\u6781\u5feb\uff0c\u6267\u884c\u5e38\u89c1\u8fd0\u7b97\u7684\u901f\u5ea6\u662f pandas \u7684 5 \u5230 10 \u500d\u3002 \u53e6\u5916\uff0cPolars \u8fd0\u7b97\u7684\u5185\u5b58\u9700\u6c42\u660e\u663e\u5c0f\u4e8e pandas\uff1apandas \u9700\u8981\u6570\u636e\u96c6\u5927\u5c0f\u7684 5 \u5230 10 \u500d\u5de6\u53f3\u7684 RAM \u6765\u6267\u884c\u8fd0\u7b97\uff0c\u800c Polars \u9700\u8981 2 \u5230 4 \u500d\u3002<\/p>\n\n\n\n<p>\u60a8\u53ef\u4ee5\u5728<a href=\"https:\/\/duckdblabs.github.io\/db-benchmark\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u8fd9\u91cc<\/a>\u4e86\u89e3 Polars \u4e0e\u5176\u4ed6 DataFrame \u5e93\u7684\u6027\u80fd\u5bf9\u6bd4\u3002 \u5bf9\u4e8e\u5e38\u89c1\u8fd0\u7b97\uff0cPolars \u7684\u901f\u5ea6\u662f pandas \u7684 10 \u5230 100 \u500d\uff0c\u4e5f\u662f\u6700\u5feb\u7684 DataFrame \u5e93\u4e4b\u4e00\u3002 \u6b64\u5916\uff0c\u5728\u5185\u5b58\u4e0d\u8db3\u9519\u8bef\u4e4b\u524d\uff0c\u5b83\u53ef\u4ee5\u5904\u7406\u6bd4 pandas \u66f4\u5927\u7684\u6570\u636e\u96c6\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"polars-\u4e3a\u4ec0\u4e48\u8fd9\u4e48\u5feb\uff1f\">Polars \u4e3a\u4ec0\u4e48\u8fd9\u4e48\u5feb\uff1f<\/h2>\n\n\n\n<p>\u8fd9\u4e9b\u7ed3\u679c\u975e\u5e38\u60ca\u4eba\uff0c\u60a8\u53ef\u80fd\u4f1a\u60f3\uff1aPolars \u662f\u600e\u4e48\u5728\u5355\u53f0\u673a\u5668\u4e0a\u8fd0\u884c\u65f6\u83b7\u5f97\u8fd9\u79cd\u6027\u80fd\u7684\uff1f \u56e0\u4e3a\uff0c\u5e93\u5728\u8bbe\u8ba1\u4e0a\u4ece\u4e00\u5f00\u59cb\u5c31\u4ee5\u6027\u80fd\u4e3a\u5b97\u65e8\uff0c\u5e76\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5b9e\u73b0\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u4ee5-rust-\u7f16\u5199\">\u4ee5 Rust \u7f16\u5199<\/h3>\n\n\n\n<p>\u5173\u4e8e Polars \u6700\u8457\u540d\u7684\u4e8b\u5b9e\u4e4b\u4e00\u662f\u5b83\u4ee5&nbsp;<a href=\"https:\/\/www.rust-lang.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Rust<\/a>&nbsp;\u7f16\u5199\uff0c\u4e00\u79cd\u51e0\u4e4e\u4e0e C \u548c C++ \u4e00\u6837\u5feb\u7684\u4f4e\u7ea7\u8bed\u8a00\u3002 \u800c pandas \u5728 Python \u5e93\u4e4b\u4e0a\u6784\u5efa\uff0c\u5176\u4e2d\u4e4b\u4e00\u662f&nbsp;<a href=\"https:\/\/numpy.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">NumPy<\/a>\u3002 \u867d\u7136 NumPy \u7684\u6838\u5fc3\u662f\u4ee5 C \u7f16\u5199\uff0c\u4f46\u5b83\u4ecd\u7136\u53d7\u5230 Python \u5904\u7406\u5185\u5b58\u4e2d\u67d0\u4e9b\u7c7b\u578b\uff08\u4f8b\u5982\u5206\u7c7b\u6570\u636e\u7684\u5b57\u7b26\u4e32\uff09\u65f6\u7684\u56fa\u6709\u95ee\u9898\u7684\u5f71\u54cd\uff0c\u5bfc\u81f4\u5904\u7406\u8fd9\u4e9b\u7c7b\u578b\u65f6\u6027\u80fd\u4e0d\u4f73\uff08\u8bf7\u53c2\u9605&nbsp;<a href=\"https:\/\/wesmckinney.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Wes McKinney<\/a>&nbsp;\u7684<a href=\"https:\/\/wesmckinney.com\/blog\/apache-arrow-pandas-internals\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u8fd9\u7bc7\u7cbe\u5f69\u535a\u6587<\/a>\uff0c\u4e86\u89e3\u66f4\u591a\u8be6\u7ec6\u4fe1\u606f\uff09\u3002<\/p>\n\n\n\n<p>\u4f7f\u7528 Rust \u7684\u53e6\u4e00\u4e2a\u4f18\u70b9\u662f\u5b83\u5141\u8bb8\u5b89\u5168\u5e76\u53d1\uff0c\u4f7f\u5e76\u884c\u6027\u5c3d\u53ef\u80fd\u53ef\u9884\u6d4b\u3002 \u8fd9\u610f\u5473\u7740 Polars \u53ef\u4ee5\u5b89\u5168\u4f7f\u7528\u6240\u6709\u673a\u5668\u6838\u5fc3\u6267\u884c\u6d89\u53ca\u591a\u4e2a\u5217\u7684\u590d\u6742\u67e5\u8be2\uff0c\u751a\u81f3\u8ba9 Ritchie Vink \u5c06 Polar \u7684\u6027\u80fd\u63cf\u8ff0\u4e3a\u201c\u8fc7\u5206\u5e76\u884c\u201d\u3002 Polars \u7684\u6027\u80fd\u56e0\u6b64\u8fdc\u9ad8\u4e8e pandas\uff0cpandas \u53ea\u4f7f\u7528\u4e00\u4e2a\u6838\u5fc3\u6267\u884c\u8fd0\u7b97\u3002 \u89c2\u770b\u4eca\u5e74 PyCon DE \u4e0a Nico Kreiling \u7684<a href=\"https:\/\/www.youtube.com\/watch?v=7xcUvzERwx0&amp;ab_channel=PyData\" target=\"_blank\" rel=\"noreferrer noopener\">\u7cbe\u5f69\u6f14\u8bb2<\/a>\uff0c\u5176\u4e2d\u8be6\u7ec6\u8bf4\u660e\u4e86 Polars \u5982\u4f55\u5b9e\u73b0\u8fd9\u4e00\u76ee\u6807\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u57fa\u4e8e-arrow\">\u57fa\u4e8e Arrow<\/h3>\n\n\n\n<p>Polars \u60ca\u4eba\u6027\u80fd\u7684\u53e6\u4e00\u4e2a\u56e0\u7d20\u662f&nbsp;<a href=\"https:\/\/arrow.apache.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Apache Arrow<\/a>\uff0c\u4e00\u79cd\u72ec\u7acb\u4e8e\u8bed\u8a00\u7684\u5185\u5b58\u683c\u5f0f\u3002 Arrow \u5b9e\u9645\u4e0a\u7531 Wes McKinney \u53c2\u4e0e\u521b\u5efa\uff0c\u4e3a\u4e86\u89e3\u51b3\u4ed6\u5728\u6570\u636e\u91cf\u7206\u70b8\u5f0f\u589e\u957f\u65f6\u5728 pandas \u4e0a\u770b\u5230\u7684\u95ee\u9898\u3002 \u5b83\u4e5f\u662f\u4eca\u5e74 3 \u6708\u53d1\u5e03\u7684\u6027\u80fd\u66f4\u9ad8\u7684 pandas \u7248\u672c pandas 2.0 \u7684\u540e\u7aef\u3002 \u4e0d\u8fc7\uff0c\u5e93\u7684 Arrow \u540e\u7aef\u7565\u6709\u4e0d\u540c\uff1a\u867d\u7136 pandas 2.0 \u57fa\u4e8e PyArrow \u6784\u5efa\uff0c\u4f46 Polars \u56e2\u961f\u6784\u5efa\u4e86\u81ea\u5df1\u7684 Arrow \u5b9e\u73b0\u3002<\/p>\n\n\n\n<p>\u5728 Arrow \u4e0a\u6784\u5efa\u6570\u636e\u5e93\u7684\u4e3b\u8981\u4f18\u70b9\u4e4b\u4e00\u662f\u4e92\u64cd\u4f5c\u6027\u3002 Arrow \u7684\u8bbe\u8ba1\u76ee\u7684\u662f\u6807\u51c6\u5316\u8de8\u5e93\u4f7f\u7528\u7684\u5185\u5b58\u6570\u636e\u683c\u5f0f\uff0c\u4e14\u5df2\u7ecf\u7528\u4e8e\u8bb8\u591a\u91cd\u8981\u7684\u5e93\u548c\u6570\u636e\u5e93\uff0c\u5982<a href=\"https:\/\/arrow.apache.org\/overview\/\" target=\"_blank\" rel=\"noreferrer noopener\">\u4e0b\u56fe<\/a>\u6240\u793a\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"574\" height=\"318\" src=\"https:\/\/blog.jetbrains.com\/wp-content\/uploads\/2023\/07\/arrow.png\" alt=\"\" class=\"wp-image-375452\"\/><\/figure>\n\n\n\n<p><a href=\"https:\/\/datapythonista.me\/blog\/pandas-20-and-the-arrow-revolution-part-i\" target=\"_blank\" rel=\"noreferrer noopener\">\u8fd9\u79cd\u4e92\u64cd\u4f5c\u6027<\/a>\u53ef\u4ee5\u63d0\u9ad8\u6027\u80fd\uff0c\u56e0\u4e3a\u5b83\u907f\u5f00\u4e86\u5c06\u6570\u636e\u8f6c\u6362\u4e3a\u4e0d\u540c\u683c\u5f0f\u4ee5\u5728\u6570\u636e\u7ba1\u9053\u7684\u4e0d\u540c\u6b65\u9aa4\u4e4b\u95f4\u4f20\u9012\u7684\u9700\u8981\uff08\u6362\u53e5\u8bdd\u8bf4\uff0c\u5b83\u907f\u514d\u4e86\u5bf9\u6570\u636e\u8fdb\u884c\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316\u7684\u9700\u8981\uff09\u3002 \u5b83\u8fd8\u5177\u6709\u66f4\u9ad8\u7684\u5185\u5b58\u6548\u7387\uff0c\u56e0\u4e3a\u4e24\u4e2a\u8fdb\u7a0b\u53ef\u4ee5\u5171\u4eab\u76f8\u540c\u7684\u6570\u636e\uff0c\u65e0\u9700\u521b\u5efa\u526f\u672c\u3002 \u636e\u4f30\u8ba1\uff0c\u5e8f\u5217\u5316\/\u53cd\u5e8f\u5217\u5316\u5360\u6570\u636e\u5de5\u4f5c\u6d41\u4e2d&nbsp;<a href=\"https:\/\/arrow.apache.org\/faq\/\" target=\"_blank\" rel=\"noreferrer noopener\">80-90% \u7684\u8ba1\u7b97\u5f00\u9500<\/a>\uff0cArrow \u7684\u901a\u7528\u6570\u636e\u683c\u5f0f\u4e3a Polars \u5e26\u6765\u4e86\u663e\u8457\u6027\u80fd\u63d0\u5347\u3002<\/p>\n\n\n\n<p>Arrow \u8fd8\u5177\u6709\u6bd4 pandas \u66f4\u5e7f\u6cdb\u7684\u6570\u636e\u7c7b\u578b\u5185\u7f6e\u652f\u6301\u3002 \u7531\u4e8e pandas \u57fa\u4e8e NumPy\uff0c\u5b83\u5728\u5904\u7406\u6574\u6570\u548c\u6d6e\u70b9\u5217\u65b9\u9762\u975e\u5e38\u51fa\u8272\uff0c\u4f46\u96be\u4ee5\u5e94\u5bf9\u5176\u4ed6\u6570\u636e\u7c7b\u578b\u3002&nbsp;<a href=\"https:\/\/datapythonista.me\/blog\/pandas-20-and-the-arrow-revolution-part-i\" target=\"_blank\" rel=\"noreferrer noopener\">\u76f8\u6bd4\u4e4b\u4e0b<\/a>\uff0cArrow \u5bf9\u65e5\u671f\u65f6\u95f4\u3001\u5e03\u5c14\u503c\u3001\u4e8c\u8fdb\u5236\u751a\u81f3\u590d\u6742\u7684\u5217\u7c7b\u578b\uff08\u4f8b\u5982\u5305\u542b\u5217\u8868\u7684\u5217\u7c7b\u578b\uff09\u63d0\u4f9b\u4e86\u590d\u6742\u7684\u652f\u6301\u3002 \u53e6\u5916\uff0cArrow \u80fd\u591f\u539f\u751f\u5904\u7406\u7f3a\u5931\u6570\u636e\uff0c\u8fd9\u5728 NumPy \u4e2d\u9700\u8981\u989d\u5916\u6b65\u9aa4\u3002<\/p>\n\n\n\n<p>\u6700\u540e\uff0cArrow \u4f7f\u7528\u5217\u5f0f\u6570\u636e\u5b58\u50a8\uff0c\u65e0\u8bba\u6570\u636e\u7c7b\u578b\u5982\u4f55\uff0c\u6240\u6709\u5217\u90fd\u5b58\u50a8\u5728\u8fde\u7eed\u5185\u5b58\u5757\u4e2d\u3002 \u8fd9\u4e0d\u4ec5\u4f7f\u5e76\u884c\u66f4\u5bb9\u6613\uff0c\u4e5f\u4f7f\u6570\u636e\u68c0\u7d22\u66f4\u5feb\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u67e5\u8be2\u4f18\u5316\">\u67e5\u8be2\u4f18\u5316<\/h3>\n\n\n\n<p>Polars \u6027\u80fd\u7684\u53e6\u4e00\u4e2a\u6838\u5fc3\u662f\u8bc4\u4f30\u4ee3\u7801\u7684\u65b9\u5f0f\u3002 Pandas \u9ed8\u8ba4\u4f7f\u7528&nbsp;<em>Eager \u6267\u884c<\/em>\uff0c\u6309\u7167\u7f16\u5199\u7684\u987a\u5e8f\u6267\u884c\u8fd0\u7b97\u3002 \u76f8\u6bd4\u4e4b\u4e0b\uff0cPolars \u80fd\u591f\u540c\u65f6\u6267\u884c Eager \u548c<em>\u60f0\u6027\u6267\u884c<\/em>\uff0c\u67e5\u8be2\u4f18\u5316\u5668\u5c06\u5bf9\u6240\u6709\u5fc5\u9700\u8fd0\u7b97\u6c42\u503c\u5e76\u5236\u5b9a\u6700\u6709\u6548\u7684\u4ee3\u7801\u6267\u884c\u65b9\u5f0f\u3002 \u8fd9\u53ef\u80fd\u5305\u62ec\u91cd\u5199\u8fd0\u7b97\u7684\u6267\u884c\u987a\u5e8f\u6216\u5220\u9664\u5197\u4f59\u8ba1\u7b97\u3002 \u4f8b\u5982\uff0c\u4f7f\u7528\u4ee5\u4e0b\u8868\u8fbe\u5f0f\u83b7\u53d6&nbsp;<code>Category<\/code>&nbsp;\u4e2d\u6bcf\u4e2a\u7c7b\u522b\u201cA\u201d\u548c\u201cB\u201d\u7684&nbsp;<code>Number1<\/code>&nbsp;\u5217\u7684\u5e73\u5747\u503c\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">(\ndf\n.groupby(by = \"Category\").agg(pl.col(\"Number1\").mean())\n.filter(pl.col(\"Category\").is_in([\"A\", \"B\"]))\n)<\/pre>\n\n\n\n<p>\u5982\u679c\u8868\u8fbe\u5f0f Eager \u6267\u884c\uff0c\u5219\u4f1a\u591a\u4f59\u5730\u5bf9\u6574\u4e2a DataFrame \u6267\u884c&nbsp;<code>groupby<\/code>&nbsp;\u8fd0\u7b97\uff0c\u7136\u540e\u6309&nbsp;<code>Category<\/code>&nbsp;\u7b5b\u9009\u3002 \u901a\u8fc7\u60f0\u6027\u6267\u884c\uff0cDataFrame \u4f1a\u7ecf\u8fc7\u7b5b\u9009\uff0c\u5e76\u4ec5\u5bf9\u6240\u9700\u6570\u636e\u6267\u884c&nbsp;<code>groupby<\/code>\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u8868\u8fbe\u6027-api\">\u8868\u8fbe\u6027 API<\/h3>\n\n\n\n<p>\u6700\u540e\uff0cPolars \u62e5\u6709\u4e00\u4e2a\u6781\u5177\u8868\u8fbe\u6027\u7684 API\uff0c\u57fa\u672c\u4e0a\u60a8\u60f3\u6267\u884c\u7684\u4efb\u4f55\u8fd0\u7b97\u90fd\u53ef\u4ee5\u7528 Polars \u65b9\u6cd5\u8868\u8fbe\u3002 \u76f8\u6bd4\u4e4b\u4e0b\uff0cpandas \u4e2d\u66f4\u590d\u6742\u7684\u8fd0\u7b97\u901a\u5e38\u9700\u8981\u4f5c\u4e3a lambda \u8868\u8fbe\u5f0f\u4f20\u9012\u7ed9&nbsp;<code>apply<\/code>&nbsp;\u65b9\u6cd5\u3002&nbsp;<code>apply<\/code>&nbsp;\u65b9\u6cd5\u7684\u95ee\u9898\u662f\u5b83\u5faa\u73af\u904d\u5386 DataFrame \u7684\u884c\uff0c\u5bf9\u6bcf\u4e00\u884c\u6309\u987a\u5e8f\u6267\u884c\u8fd0\u7b97\u3002 \u5185\u7f6e\u65b9\u6cd5\u80fd\u591f\u8ba9\u60a8\u5728\u5217\u7ea7\u522b\u4e0a\u5de5\u4f5c\u5e76\u5229\u7528\u53e6\u4e00\u79cd\u79f0\u4e3a SIMD \u7684\u5e76\u884c\u5f62\u5f0f\u3002 <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u4ec0\u4e48\u65f6\u5019\u5e94\u8be5\u7ee7\u7eed\u4f7f\u7528-pandas\uff1f\">\u4ec0\u4e48\u65f6\u5019\u5e94\u8be5\u7ee7\u7eed\u4f7f\u7528 pandas\uff1f<\/h2>\n\n\n\n<p>\u6240\u6709\u8fd9\u4e9b\u542c\u8d77\u6765\u90fd\u5f88\u68d2\uff0c\u4f60\u53ef\u80fd\u4f1a\u60f3\u6211\u4eec\u4e3a\u4ec0\u4e48\u8fd8\u8981\u4f7f\u7528 pandas\u3002\u4e3b\u8981\u539f\u56e0\u662f pandas \u4e0e\u6574\u4e2a Python \u6570\u636e\u79d1\u5b66\u751f\u6001\u7cfb\u7edf\u4e00\u8d77\u6210\u957f\uff0c\u4ecd\u7136\u4e0e\u6784\u6210\u673a\u5668\u5b66\u4e60\u6d41\u6c34\u7ebf\u7684\u5176\u4ed6\u8f6f\u4ef6\u5305\u5177\u6709\u6700\u5927\u7684\u4e92\u64cd\u4f5c\u6027\u3002<\/p>\n\n\n\n<p>\u7136\u800c\uff0cPolars \u6b63\u5728\u8fce\u5934\u8d76\u4e0a\uff0c\u5b83\u4e0e\u8fd9\u4e9b\u8f6f\u4ef6\u5305\u7684\u4e92\u64cd\u4f5c\u6027\u9010\u6708\u589e\u957f\u3002Polars \u73b0\u5728\u517c\u5bb9\u591a\u79cd\u7ed8\u56fe\u5e93\uff0c\u5305\u62ec <code>plotly<\/code>\u3001<code>matplotlib<\/code>\uff08\u4f7f\u7528 Series \u65f6\u9664\u5916\uff09\u3001<code>seaborn<\/code>\u3001<code>altair<\/code> \u548c <code>hvplot<\/code>\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u73b0\u5728\u4f5c\u4e3a\u63a2\u7d22\u6027\u6570\u636e\u5206\u6790\u5e93\u4e5f\u5f88\u597d\u7528\u3002<\/p>\n\n\n\n<p>\u73b0\u5728\u8fd8\u53ef\u4ee5\u5c06 Polars DataFrame \u7528\u4f5c\u673a\u5668\u5b66\u4e60\u548c\u6df1\u5ea6\u5b66\u4e60\u6d41\u6c34\u7ebf\u7684\u4e00\u90e8\u5206\u3002\u4ece <code>scikit-learn<\/code> \u7248\u672c 1.4.0 \u5f00\u59cb\uff0c\u53ef\u4ee5<a href=\"https:\/\/scikit-learn.org\/dev\/auto_examples\/release_highlights\/plot_release_highlights_1_4_0.html#polars-output-in-set-output\" data-type=\"link\" data-id=\"https:\/\/scikit-learn.org\/dev\/auto_examples\/release_highlights\/plot_release_highlights_1_4_0.html#polars-output-in-set-output\" target=\"_blank\" rel=\"noopener\">\u5c06 transformers \u8f93\u51fa\u4e3a Polars DataFrames<\/a>\u3002\u73b0\u5728\u8fd8\u53ef\u4ee5\u5c06 Polars DataFrames \u8f6c\u6362\u4e3a PyTorch \u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec PyTorch Tensor\u3001PolarsDataset\uff08\u6846\u67b6\u4e13\u7528\u7684 TensorDataset\uff09\u6216 Tensors \u5b57\u5178\u3002\u8fd9\u53ef\u4ee5<a href=\"https:\/\/docs.pola.rs\/api\/python\/stable\/reference\/dataframe\/api\/polars.DataFrame.to_torch.html\" data-type=\"link\" data-id=\"https:\/\/docs.pola.rs\/api\/python\/stable\/reference\/dataframe\/api\/polars.DataFrame.to_torch.html\" target=\"_blank\" rel=\"noopener\">\u5728 Polars \u4e2d<\/a>\u901a\u8fc7\u5bf9 DataFrame \u8c03\u7528 <code>to_torch<\/code> \u65b9\u6cd5\u6765\u5b9e\u73b0\u3002<\/p>\n\n\n\n<p>\u6240\u6709\u8fd9\u4e9b\u90fd\u662f\u5f00\u6e90\u9879\u76ee\uff0c\u7ef4\u62a4\u8005\u6295\u5165\u4e86\u5927\u91cf\u65f6\u95f4\u6765\u4f7f\u8fd9\u4e9b\u5305\u534f\u540c\u5de5\u4f5c\u3002\u975e\u5e38\u611f\u8c22\u6240\u6709\u53c2\u4e0e\u8fd9\u4e9b\u9879\u76ee\u7684\u4eba\u2014\u2014\u8fd9\u65e0\u7591\u662f\u6570\u636e\u79d1\u5b66\u9886\u57df\u6fc0\u52a8\u4eba\u5fc3\u7684\u65f6\u523b\uff01\uff08\u6b64\u5916\uff0c\u8fd8\u8981\u611f\u8c22 Ritchie Vink \u5f3a\u8c03\u8fd9\u4e9b\u8fdb\u6b65\uff01\uff09<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Polars \u548c pandas \u7684\u5de5\u5177<\/h2>\n\n\n\n<p>\u8bfb\u5b8c\u8fd9\u4e9b\uff0c\u6211\u76f8\u4fe1\u60a8\u4e00\u5b9a\u8feb\u4e0d\u53ca\u5f85\u5730\u60f3\u8981\u4eb2\u81ea\u5c1d\u8bd5\u4e00\u4e0b Polars\uff01<a href=\"https:\/\/www.jetbrains.com.cn\/pycharm\/data-science\/\" data-type=\"link\" data-id=\"https:\/\/www.jetbrains.com.cn\/pycharm\/data-science\/\" target=\"_blank\" rel=\"noopener\">\u9002\u7528\u4e8e\u6570\u636e\u79d1\u5b66\u7684 PyCharm Professional<\/a> \u4e3a\u5728 Jupyter Notebook \u4e2d\u4f7f\u7528 pandas \u548c Polars \u63d0\u4f9b\u4e86\u51fa\u8272\u7684\u5de5\u5177\u3002\u7279\u522b\u662f pandas \u548c Polars DataFrames \u5177\u6709\u4ea4\u4e92\u529f\u80fd\uff0c\u4f7f\u60a8\u80fd\u591f\u66f4\u5feb\u3001\u66f4\u8212\u9002\u5730\u63a2\u7d22\u6570\u636e\u3002<\/p>\n\n\n\n<p>\u6211\u6700\u559c\u6b22\u7684\u4e00\u4e9b\u529f\u80fd\u5305\u62ec\u80fd\u591f\u6eda\u52a8\u6d4f\u89c8 DataFrame \u7684\u6240\u6709\u884c\u548c\u5217\u800c\u4e0d\u4f1a\u622a\u65ad\u3001\u4e00\u952e\u83b7\u53d6 DataFrame \u503c\u7684\u805a\u5408\u548c\u4ee5\u591a\u79cd\u683c\u5f0f\uff08\u5305\u62ec Markdown\uff01\uff09\u5bfc\u51fa DataFrame\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u60a8\u5c1a\u672a\u4f7f\u7528 PyCharm\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u94fe\u63a5\u8bd5\u7528 30 \u5929\u3002<\/p>\n\n\n\n<p align=\"center\">\n    <a class=\"jb-download-button\" href=\"https:\/\/www.jetbrains.com.cn\/pycharm\/data-science\/\" target=\"_blank\" rel=\"noopener\">      \n        \u5f00\u59cb PyCharm Pro \u514d\u8d39\u8bd5\u7528\n    <\/a>\n<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u672c\u535a\u6587\u82f1\u6587\u539f\u4f5c\u8005\uff1a<\/p>\n\n\n    <div class=\"about-author \">\n        <div class=\"about-author__box\">\n            <div class=\"row\">\n                <div class=\"about-author__box-img\">\n                    <img decoding=\"async\" src=\"https:\/\/secure.gravatar.com\/avatar\/?s=200&#038;r=g\" width=\"200\" height=\"200\" alt=\"\" loading=\"lazy\"  class=\"avatar avatar-200 wp-user-avatar wp-user-avatar-200 photo avatar-default\">\n                <\/div>\n                <div class=\"about-author__box-text\">\n                                                        <\/div>\n            <\/div>\n        <\/div>\n    <\/div>\n","protected":false},"author":1297,"featured_media":490607,"comment_status":"closed","ping_status":"closed","template":"","categories":[952],"tags":[566,8152],"cross-post-tag":[],"acf":[],"_links":{"self":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/pycharm\/492158"}],"collection":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/pycharm"}],"about":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/types\/pycharm"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/users\/1297"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/comments?post=492158"}],"version-history":[{"count":9,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/pycharm\/492158\/revisions"}],"predecessor-version":[{"id":495251,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/pycharm\/492158\/revisions\/495251"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/media\/490607"}],"wp:attachment":[{"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/media?parent=492158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/categories?post=492158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/tags?post=492158"},{"taxonomy":"cross-post-tag","embeddable":true,"href":"https:\/\/blog.jetbrains.com\/zh-hans\/wp-json\/wp\/v2\/cross-post-tag?post=492158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}