Skills2026年3月31日·1 分钟阅读

PandasAI — Chat with Your Data Using AI

Conversational data analysis with LLMs. Chat with SQL databases, CSV, Parquet files using natural language. Auto-generates Python/SQL and visualizations. 23K+ stars.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
PandasAI — Chat with Your Data Using AI
直接安装命令
npx -y tokrepo@latest install 1de69db6-ca54-422f-aa57-297cd63a016b --target codex

先 dry-run 确认安装计划,再运行此命令。

TL;DR
PandasAI lets you chat with SQL databases, CSV, and Parquet files using natural language queries.
§01

What it is

PandasAI is a Python library that adds conversational capabilities to data analysis. You ask questions about your data in natural language, and PandasAI generates the Python code or SQL query to answer them. It works with pandas DataFrames, SQL databases, CSV files, and Parquet files. It can also generate visualizations automatically.

PandasAI targets data analysts, scientists, and business users who want to explore datasets without writing code manually. It bridges the gap between natural language questions and programmatic data analysis.

§02

How it saves time or tokens

PandasAI eliminates the translation step between 'what do I want to know' and 'how do I write the code.' Instead of composing groupby, merge, and pivot operations manually, you describe what you need. The library generates and executes the code, returning results or charts. For exploratory analysis where you run dozens of ad-hoc queries, this reduces each query from minutes to seconds. Estimated token usage is around 500 tokens per query.

§03

How to use

  1. Install PandasAI:
pip install pandasai
  1. Create a SmartDataframe and ask questions:
import pandas as pd
from pandasai import SmartDataframe

df = pd.DataFrame({
    'country': ['USA', 'China', 'Japan', 'Germany', 'India'],
    'gdp': [21400, 14700, 5100, 3800, 2900],
    'population': [331, 1400, 126, 83, 1380]
})

sdf = SmartDataframe(df)
result = sdf.chat('Which country has the highest GDP per capita?')
print(result)
  1. Generate visualizations:
sdf.chat('Plot a bar chart of GDP by country')
# Generates and displays a matplotlib chart
§04

Example

Connecting to a SQL database:

from pandasai import SmartDataframe
from pandasai.connectors import PostgreSQLConnector

connector = PostgreSQLConnector(
    config={
        'host': 'localhost',
        'port': 5432,
        'database': 'analytics',
        'username': 'user',
        'password': 'pass',
        'table': 'sales'
    }
)

sdf = SmartDataframe(connector)
sdf.chat('What were the total sales by region last quarter?')
§05

Related on TokRepo

§06

Common pitfalls

  • PandasAI executes generated code automatically. Review the generated code before running on sensitive datasets, especially when connected to production databases.
  • Complex multi-step queries sometimes produce incorrect code. Break complex questions into simpler sub-questions for more reliable results.
  • LLM API costs accumulate during heavy exploratory sessions. Consider using local models via Ollama for high-volume analysis.

常见问题

Does PandasAI work with local LLMs?+

Yes. PandasAI supports Ollama and other local model providers. Configure the LLM parameter to point to your local endpoint, eliminating API costs for exploratory sessions.

Can PandasAI connect to SQL databases directly?+

Yes. PandasAI provides connectors for PostgreSQL, MySQL, and other databases. It generates SQL queries or loads data into DataFrames depending on the question complexity.

Is PandasAI safe for production data?+

PandasAI executes generated Python code, which carries risk. Use read-only database credentials and review generated code before execution. Do not point it at production databases without safeguards.

What types of visualizations can it create?+

PandasAI generates matplotlib and seaborn charts including bar charts, line plots, scatter plots, histograms, and pie charts. Specify the chart type in your natural language query.

How accurate are the generated queries?+

Accuracy depends on the LLM model used and the clarity of your question. Simple aggregations and filters are highly reliable. Complex joins or multi-step transformations may require iteration or manual correction.

引用来源 (3)
🙏

来源与感谢

Created by Sinaptik AI. Licensed under custom license. Sinaptik-AI/pandas-ai — 23,000+ GitHub stars

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产