Pandasai是一個Python平台,可以輕鬆以自然語言向您的數據提出問題。它可以幫助非技術用戶以更自然的方式與數據進行交互,並幫助技術用戶在處理數據時節省時間和精力。
Pandasai可以通過多種方式使用。您可以在Jupyter筆記本或簡化應用程序中輕鬆使用它,也可以將其部署為REST API,例如使用FastAPI或Flask。
如果您對託管Pandasai Cloud或我們的自我託管企業提供感興趣,請與我們聯繫。
您可以在此處找到Pandasai的完整文檔。
您可以決定在Jupyter筆記本電腦,簡化應用程序中使用Pandasai,也可以使用Repo中的客戶端和服務器體系結構。

Pandasai平台使用Dockerized客戶端服務器架構。您將需要在計算機中安裝Docker。
git clone https://github.com/sinaptik-ai/pandas-ai/
cd pandas-ai
docker-compose build構建平台後,您可以運行以下操作:
docker-compose up這將啟動客戶端和服務器,您可以通過http://localhost:3000訪問客戶端。
您可以使用Pip或Poetry安裝Pandasai庫。
與pip:
pip install pandasai詩歌:
poetry add pandasai您自己在瀏覽器中自己嘗試Pandasai庫:
import os
import pandas as pd
from pandasai import Agent
# Sample DataFrame
sales_by_country = pd . DataFrame ({
"country" : [ "United States" , "United Kingdom" , "France" , "Germany" , "Italy" , "Spain" , "Canada" , "Australia" , "Japan" , "China" ],
"revenue" : [ 5000 , 3200 , 2900 , 4100 , 2300 , 2100 , 2500 , 2600 , 4500 , 7000 ]
})
# By default, unless you choose a different LLM, it will use BambooLLM.
# You can get your free API key signing up at https://pandabi.ai (you can also configure it in your .env file)
os . environ [ "PANDASAI_API_KEY" ] = "YOUR_API_KEY"
agent = Agent ( sales_by_country )
agent . chat ( 'Which are the top 5 countries by sales?' ) China, United States, Japan, Germany, Australia
或者您可以提出更多複雜的問題:
agent . chat (
"What is the total sales for the top 3 countries by sales?"
) The total sales for the top 3 countries by sales is 16500.
您也可以要求Pandasai為您生成圖表:
agent . chat (
"Plot the histogram of countries showing for each one the gd. Use different colors for each bar" ,
)
您還可以將多個數據范圍傳遞給Pandasai,並提出有關它們的問題。
import os
import pandas as pd
from pandasai import Agent
employees_data = {
'EmployeeID' : [ 1 , 2 , 3 , 4 , 5 ],
'Name' : [ 'John' , 'Emma' , 'Liam' , 'Olivia' , 'William' ],
'Department' : [ 'HR' , 'Sales' , 'IT' , 'Marketing' , 'Finance' ]
}
salaries_data = {
'EmployeeID' : [ 1 , 2 , 3 , 4 , 5 ],
'Salary' : [ 5000 , 6000 , 4500 , 7000 , 5500 ]
}
employees_df = pd . DataFrame ( employees_data )
salaries_df = pd . DataFrame ( salaries_data )
# By default, unless you choose a different LLM, it will use BambooLLM.
# You can get your free API key signing up at https://pandabi.ai (you can also configure it in your .env file)
os . environ [ "PANDASAI_API_KEY" ] = "YOUR_API_KEY"
agent = Agent ([ employees_df , salaries_df ])
agent . chat ( "Who gets paid the most?" ) Olivia gets paid the most.
您可以在示例目錄中找到更多示例。
為了生成用於運行的Python代碼,我們從數據框架中獲取一些隨機樣本,我們將其隨機化(使用隨機生成敏感數據並進行非敏感數據進行改組),然後將隨機頭髮送到LLM。
如果您想進一步執行您的隱私,則可以用enforce_privacy = True實例化Pandasai,這不會將頭(但僅將列名)發送到LLM。
Pandasai可根據MIT Expat許可證提供,除pandasai/ee目錄(如果適用,則在此處具有許可證。
如果您對託管Pandasai Cloud或自主企業提供感興趣,請與我們聯繫。
歡迎捐款!請檢查出色的問題,並隨時打開拉動請求。有關更多信息,請查看貢獻指南。