{"id":13232,"date":"2024-11-14T12:08:14","date_gmt":"2024-11-14T04:08:14","guid":{"rendered":"https:\/\/www.aisharenet.com\/?p=13232"},"modified":"2024-11-14T01:29:04","modified_gmt":"2024-11-13T17:29:04","slug":"pandasai","status":"publish","type":"post","link":"https:\/\/www.kdjingpai.com\/pt\/pandasai\/","title":{"rendered":"PandasAI\uff1a\u6570\u636e\u5206\u6790\u5bf9\u8bdd\u5e73\u53f0\uff0c\u7528\u81ea\u7136\u8bed\u8a00\u5b8c\u6210\u6570\u636e\u67e5\u8be2\u4e0e\u56fe\u8868\u751f\u6210"},"content":{"rendered":"<p>PandasAI\u662f\u4e00\u4e2a\u57fa\u4e8ePython\u7684\u5f00\u6e90\u5e73\u53f0\uff0c\u65e8\u5728\u901a\u8fc7\u81ea\u7136\u8bed\u8a00\u5904\u7406\u6280\u672f\u7b80\u5316\u6570\u636e\u5206\u6790\u8fc7\u7a0b\u3002\u4f7f\u7528\u6237\u80fd\u591f\u4ee5\u5bf9\u8bdd\u7684\u65b9\u5f0f\u4e0e\u6570\u636e\u5e93\uff08\u5982 SQL\u3001CSV\u3001pandas\u3001polars\u3001mongodb\u3001noSQL \u7b49\uff09\u8fdb\u884c\u4ea4\u4e92\u3002\u8be5\u5e73\u53f0\u5229\u7528\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff08\u5982 GPT-3.5\/4\u3001Anthropic\u3001VertexAI\uff09\u548c\u68c0\u7d22\u589e\u5f3a\u751f\u6210\uff08RAG\uff09\u6280\u672f\uff0c\u4f7f\u6570\u636e\u5206\u6790\u53d8\u5f97\u66f4\u52a0\u76f4\u89c2\u548c\u9ad8\u6548\uff0c\u9002\u7528\u4e8e\u6280\u672f\u548c\u975e\u6280\u672f\u7528\u6237\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter  wp-image-13233\" title=\"PandasAI\uff1a\u6570\u636e\u5206\u6790\u5bf9\u8bdd\u5e73\u53f0\uff0c\u7528\u81ea\u7136\u8bed\u8a00\u5b8c\u6210\u6570\u636e\u67e5\u8be2\u4e0e\u56fe\u8868\u751f\u6210-1\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/11\/78a68a0f1f4e0ee.png\" alt=\"PandasAI\uff1a\u6570\u636e\u5206\u6790\u5bf9\u8bdd\u5e73\u53f0\uff0c\u7528\u81ea\u7136\u8bed\u8a00\u5b8c\u6210\u6570\u636e\u67e5\u8be2\u4e0e\u56fe\u8868\u751f\u6210-1\" width=\"967\" height=\"606\" srcset=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/11\/78a68a0f1f4e0ee.png 1273w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/11\/78a68a0f1f4e0ee-300x188.png 300w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/11\/78a68a0f1f4e0ee-1024x641.png 1024w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/11\/78a68a0f1f4e0ee-768x481.png 768w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/11\/78a68a0f1f4e0ee-18x12.png 18w\" sizes=\"auto, (max-width: 967px) 100vw, 967px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13234\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/11\/edbcf5621b04a86.gif\" alt=\"\" width=\"800\" height=\"500\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>\u529f\u80fd\u5217\u8868<\/h2>\n<ul>\n<li><strong>\u81ea\u7136\u8bed\u8a00\u67e5\u8be2<\/strong>\uff1a\u901a\u8fc7\u81ea\u7136\u8bed\u8a00\u63d0\u95ee\uff0c\u8f7b\u677e\u83b7\u53d6\u6570\u636e\u5206\u6790\u7ed3\u679c\u3002<\/li>\n<li><strong>\u6570\u636e\u53ef\u89c6\u5316<\/strong>\uff1a\u751f\u6210\u56fe\u8868\u548c\u56fe\u5f62\uff0c\u76f4\u89c2\u5c55\u793a\u6570\u636e\u3002<\/li>\n<li><strong>\u6570\u636e\u6e05\u6d17<\/strong>\uff1a\u5904\u7406\u7f3a\u5931\u503c\uff0c\u63d0\u5347\u6570\u636e\u8d28\u91cf\u3002<\/li>\n<li><strong>\u7279\u5f81\u751f\u6210<\/strong>\uff1a\u901a\u8fc7\u751f\u6210\u65b0\u7279\u5f81\uff0c\u589e\u5f3a\u6570\u636e\u96c6\u3002<\/li>\n<li><strong>\u591a\u6570\u636e\u6e90\u652f\u6301<\/strong>\uff1a\u8fde\u63a5CSV\u3001XLSX\u3001PostgreSQL\u3001MySQL\u3001BigQuery\u7b49\u591a\u79cd\u6570\u636e\u6e90\u3002<\/li>\n<li><strong>\u591a\u6a21\u578b\u652f\u6301<\/strong>\uff1a\u96c6\u6210GPT 3.5\/4\u3001Anthropic\u3001VertexAI\u7b49\u591a\u79cd\u8bed\u8a00\u6a21\u578b\u3002<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2>\u4f7f\u7528\u5e2e\u52a9<\/h2>\n<h3>\u5b89\u88c5\u6d41\u7a0b<\/h3>\n<ol>\n<li><strong>\u5b89\u88c5Docker<\/strong>\u00a0\uff1a\u786e\u4fdd\u60a8\u7684\u673a\u5668\u4e0a\u5df2\u5b89\u88c5Docker\u3002<\/li>\n<li><strong>\u514b\u9686\u4ed3\u5e93<\/strong>\u00a0\uff1a\u8fd0\u884c<code>git clone https:\/\/github.com\/Sinaptik-AI\/pandas-ai<\/code>\u3002<\/li>\n<li><strong>\u6784\u5efa\u5e73\u53f0<\/strong>\u00a0\uff1a\u8fdb\u5165\u9879\u76ee\u76ee\u5f55\u5e76\u8fd0\u884c<code>docker-compose build<\/code>\u3002<\/li>\n<li><strong>\u542f\u52a8\u5e73\u53f0<\/strong>\u00a0\uff1a\u8fd0\u884c<code>docker-compose up<\/code>\uff0c\u7136\u540e\u8bbf\u95ee<code>http:\/\/localhost:3000<\/code>\u3002<\/li>\n<\/ol>\n<h3>\u4f7f\u7528PandasAI\u5e93<\/h3>\n<ol>\n<li><strong>\u5b89\u88c5\u5e93<\/strong>\u00a0\uff1a\n<ul>\n<li>\u4f7f\u7528pip\uff1a<code>pip install pandasai<\/code><\/li>\n<li>\u4f7f\u7528poetry\uff1a<code>poetry add pandasai<\/code><\/li>\n<\/ul>\n<\/li>\n<li><strong>\u5bfc\u5165\u5e93<\/strong>\u00a0\uff1a<\/li>\n<\/ol>\n<pre><code>import os\r\nimport pandas as pd\r\nfrom pandasai import Agent\r\n<\/code><\/pre>\n<ol>\n<li><strong>\u521b\u5efa\u6570\u636e\u6846<\/strong>\u00a0\uff1a<\/li>\n<\/ol>\n<pre><code>sales_by_country = pd.DataFrame({\r\n\"country\": [\"United States\", \"United Kingdom\", \"France\", \"Germany\", \"Italy\", \"Spain\", \"Canada\", \"Australia\", \"Japan\", \"China\"],\r\n\"revenue\": [5000, 3200, 2900, 4100, 2300, 2100, 2500, 2600, 4500, 7000]\r\n})\r\n<\/code><\/pre>\n<ol>\n<li><strong>\u914d\u7f6eAPI\u5bc6\u94a5<\/strong>\u00a0\uff1a<\/li>\n<\/ol>\n<pre><code>os.environ[\"PANDASAI_API_KEY\"] = \"YOUR_API_KEY\"\r\n<\/code><\/pre>\n<ol>\n<li><strong>\u521b\u5efaAgent\u5e76\u67e5\u8be2<\/strong>\u00a0\uff1a<\/li>\n<\/ol>\n<pre><code>agent = Agent(sales_by_country)\r\nresponse = agent.chat('Which are the top 5 countries by sales?')\r\nprint(response)\r\n<\/code><\/pre>\n<ol>\n<li><strong>\u751f\u6210\u56fe\u8868<\/strong>\u00a0\uff1a<\/li>\n<\/ol>\n<pre><code>agent.chat(\"Plot the histogram of countries showing for each one the gd. Use different colors for each bar\")\r\n<\/code><\/pre>\n<h3>\u4f7f\u7528PandasAI\u5e73\u53f0<\/h3>\n<ol>\n<li><strong>\u8bbf\u95ee\u5e73\u53f0<\/strong>\u00a0\uff1a\u542f\u52a8\u540e\u8bbf\u95ee<code>http:\/\/localhost:3000<\/code>\u3002<\/li>\n<li><strong>\u4e0a\u4f20\u6570\u636e<\/strong>\u00a0\uff1a\u901a\u8fc7\u754c\u9762\u4e0a\u4f20CSV\u6216Excel\u6587\u4ef6\u3002<\/li>\n<li><strong>\u81ea\u7136\u8bed\u8a00\u67e5\u8be2<\/strong>\u00a0\uff1a\u5728\u67e5\u8be2\u6846\u4e2d\u8f93\u5165\u95ee\u9898\uff0c\u4f8b\u5982\u201cWhich are the top 5 countries by sales?\u201d\u3002<\/li>\n<li><strong>\u67e5\u770b\u7ed3\u679c<\/strong>\u00a0\uff1a\u5e73\u53f0\u5c06\u8fd4\u56de\u67e5\u8be2\u7ed3\u679c\uff0c\u5e76\u53ef\u9009\u62e9\u751f\u6210\u76f8\u5e94\u7684\u56fe\u8868\u3002<\/li>\n<\/ol>\n<p>PandasAI \u9002\u7528\u4e8e\u5404\u79cd\u6570\u636e\u5206\u6790\u573a\u666f\uff0c\u65e0\u8bba\u662f\u5546\u4e1a\u5206\u6790\u3001\u5b66\u672f\u7814\u7a76\u8fd8\u662f\u4e2a\u4eba\u9879\u76ee\u3002\u901a\u8fc7\u81ea\u7136\u8bed\u8a00\u5904\u7406\u6280\u672f\uff0c\u7528\u6237\u53ef\u4ee5\u8f7b\u677e\u5730\u4ece\u6570\u636e\u4e2d\u83b7\u53d6\u6709\u4ef7\u503c\u7684\u4fe1\u606f\uff0c\u800c\u65e0\u9700\u7f16\u5199\u590d\u6742\u7684\u4ee3\u7801\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PandasAI\u662f\u4e00\u4e2a\u57fa\u4e8ePython\u7684\u5f00\u6e90\u5e73\u53f0\uff0c\u65e8\u5728\u901a\u8fc7\u81ea\u7136\u8bed\u8a00\u5904\u7406\u6280\u672f\u7b80\u5316\u6570\u636e\u5206\u6790\u8fc7\u7a0b\u3002\u4f7f\u7528\u6237\u80fd\u591f\u4ee5\u5bf9\u8bdd\u7684\u65b9\u5f0f\u4e0e\u6570\u636e\u5e93\uff08\u5982 SQL\u3001CSV\u3001pandas\u3001polars\u3001mongodb\u3001noSQL \u7b49\uff09\u8fdb\u884c\u4ea4\u4e92\u3002\u8be5\u5e73\u53f0\u5229\u7528\u5927\u578b\u8bed\u8a00\u6a21\u578b\uff08\u5982&#8230;<\/p>\n","protected":false},"author":1,"featured_media":61236,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[230,244],"class_list":["post-13232","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tool","tag-aikaiyuanxiangmu","tag-aishujufenxi"],"_links":{"self":[{"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/posts\/13232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/comments?post=13232"}],"version-history":[{"count":0,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/posts\/13232\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/media\/61236"}],"wp:attachment":[{"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/media?parent=13232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/categories?post=13232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/pt\/wp-json\/wp\/v2\/tags?post=13232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}