https://github.com/Sinaptik-AI/pandas-ai
https://docs.pandas-ai.com/llms PandasAI 支持几种大型语言模型 (LLM),用于从自然语言查询生成代码。
使用pip安装
pip install pandasai
绘制国家直方图,显示每个国家的 gd。为每个条形使用不同的颜色
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(
"Plot the histogram of countries showing for each one the gd. Use different colors for each bar",
)