pandas-ai
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "pandas-ai":https://skillpi.com/zh/skills/deepskill-f7836a3c79414592bd632657cba34a77eda51b1a86880b3e9bfe8799d5619166。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
PandasAI 专家:使用大语言模型(LLMs)对 pandas DataFrame 进行自然语言查询的支持。学习如何用简单英语提问、生成图表、清洗数据,并集成 OpenAI 与本地模型,实现对话式数据分析。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: pandas-ai
description: |
PandasAI enables natural language queries on pandas DataFrames using LLMs.
Learn to ask questions in plain English, generate charts, clean data,
and integrate with OpenAI and local models for conversational data analysis.
license: Apache-2.0
compatibility: 'macos, linux, windows'
metadata:
author: terminal-skills
version: 1.0.0
category: data-ai
tags:
- pandas-ai
- pandas
- llm
- natural-language
- data-analysisPandasAI
PandasAI adds natural language capabilities to pandas. Ask questions about your data in English and get answers, charts, and transformations — powered by LLMs.
Installation
# Install PandasAI
pip install pandasai
# With OpenAI
pip install pandasai[openai]
# With local models via Ollama
pip install pandasai[langchain]
Basic Usage
# basic.py: Ask questions about a DataFrame in natural language
import pandas as pd
from pandasai import SmartDataframe
from pandasai.llm import OpenAI
llm = OpenAI(api_token="your-openai-api-key")
df = pd.DataFrame({
"country": ["USA", "UK", "France", "Germany", "Japan"],
"population": [331_000_000, 67_000_000, 67_000_000, 83_000_000, 125_000_000],
"gdp_billion": [25_460, 3_070, 2_780, 4_070, 4_230],
})
sdf = SmartDataframe(df, config={"llm": llm})
# Ask questions in natural language
answer = sdf.chat("Which country has the highest GDP?")
print(answer) # USA
answer = sdf.chat("What is the average population?")
print(answer) # 134,600,000
answer = sdf.chat("List countries with GDP above 4000 billion")
print(answer)
Multiple DataFrames
# multi-df.py: Query across multiple related DataFrames
from pandasai import SmartDatalake
employees = pd.DataFrame({
"id": [1, 2, 3, 4, 5],
"name": ["Alice", "Bob", "Charlie", "Diana", "Eve"],
"department_id": [1, 2, 1, 3, 2],
"salary": [85000, 72000, 90000, 68000, 95000],
})
departments = pd.DataFrame({
"id": [1, 2, 3],
"name": ["Engineering", "Marketing", "Sales"],
"budget": [500000, 200000, 300000],
})
lake = SmartDatalake([employees, departments], config={"llm": llm})
result = lake.chat("What is the average salary per department?")
print(result)
result = lake.chat("Which department is over budget based on total salaries?")
print(result)
Generate Charts
# charts.py: Create visualizations from natural language
sdf = SmartDataframe(df, config={
"llm": llm,
"save_charts": True,
"save_charts_path": "./charts",
})
# Generate charts by asking
sdf.chat("Create a bar chart of GDP by country")
sdf.chat("Plot a pie chart of population distribution")
sdf.chat("Show a scatter plot of GDP vs population")
# Charts saved as PNG in ./charts/
Data Cleaning
# cleaning.py: Use natural language for data cleaning tasks
dirty_df = pd.DataFrame({
"name": ["Alice", "bob", "CHARLIE", None, "Eve"],
"email": ["alice@co.com", "invalid", "charlie@co.com", "diana@co.com", ""],
"age": [30, -5, 45, 200, 28],
"salary": [85000, 72000, None, 68000, 95000],
})
sdf = SmartDataframe(dirty_df, config={"llm": llm})
# Clean with natural language
cleaned = sdf.chat("Remove rows where age is negative or above 150")
cleaned = sdf.chat("Fill missing salaries with the median salary")
cleaned = sdf.chat("Standardize names to title case")
cleaned = sdf.chat("Remove rows with invalid email addresses")
Custom Configuration
# config.py: Advanced PandasAI configuration
from pandasai import SmartDataframe
sdf = SmartDataframe(df, config={
"llm": llm,
"conversational": True, # Natural language responses
"verbose": True, # Show generated code
"enable_cache": True, # Cache repeated queries
"max_retries": 3, # Retry on LLM errors
"custom_whitelisted_dependencies": ["scipy", "sklearn"],
"save_logs": True,
})
# View the generated Python code
sdf.chat("What is the correlation between GDP and population?")
print(sdf.last_code_generated)
Using Local Models
# local-llm.py: Use Ollama or other local models instead of OpenAI
from pandasai.llm.local_llm import LocalLLM
# With Ollama running locally
llm = LocalLLM(api_base="http://localhost:11434/v1", model="llama3")
sdf = SmartDataframe(df, config={"llm": llm})
answer = sdf.chat("Summarize this dataset")
print(answer)
Pipeline Integration
# pipeline.py: Use PandasAI in an automated analysis pipeline
from pandasai import SmartDataframe
from pandasai.llm import OpenAI
import pandas as pd
import json
def analyze_dataset(csv_path: str, questions: list[str]) -> dict:
"""Run a set of natural language questions against a CSV dataset."""
llm = OpenAI(api_token="your-key")
df = pd.read_csv(csv_path)
sdf = SmartDataframe(df, config={"llm": llm, "conversational": True})
results = {}
for question in questions:
try:
answer = sdf.chat(question)
results[question] = str(answer)
except Exception as e:
results[question] = f"Error: {e}"
return results
# Usage
report = analyze_dataset("sales.csv", [
"What was the total revenue last month?",
"Which product category had the most sales?",
"What is the month-over-month growth rate?",
])
print(json.dumps(report, indent=2))当前收录版本
1.0.0
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供自然语言查询 pandas 数据框的能力,显著提升数据分析效率
- 支持生成图表、数据清洗、多数据框操作等完整数据分析流程
- 集成 OpenAI 和本地模型,满足不同部署需求
亮点
- description 明确描述核心功能,触发词精准完整
- 覆盖自然语言查询、图表生成、数据清洗、模型集成等关键场景
亮点
- 文档结构清晰,包含完整的使用章节和端到端示例
- frontmatter 完整,单文件长度合理,易于理解执行流程
亮点
- 提供完整的安装命令和配置说明
- 包含异常处理示例和缓存重试机制,执行可靠性高
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 29, 32, 35 行 -
账号、密钥或授权
使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。
主文档提及 · 第 46 行
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- localhost
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。