Pandasai
A Python library that adds a chat method to your dataframes: it generates and runs pandas code to answer questions, with an optional Docker sandbox.
PandasAI is a Python library from Sinaptik GmbH that makes dataframes conversational: load a CSV or connect a database, call .chat() with a plain-English question, and it generates and executes the code to answer it. An experimental semantic layer adds column descriptions, and an optional Docker sandbox isolates the generated code.
PandasAI is the smallest possible version of the idea behind every AI data tool: put a .chat() method on a dataframe. You load a CSV, configure a model, ask a question in English, and the library writes Python, runs it, and hands back the answer. Nothing is hosted, nothing is a platform, and the whole thing fits in a notebook cell.
That makes it a good fit for analysts who already work in Python and want conversational analysis inside a script or notebook rather than in a vendor's web app. It also makes the security question yours to answer, because the code that runs is code a language model just generated.
Highlights
- Chat over one dataframe or several.
df.chat("What is the average revenue by region?")returns a value;pai.chat(question, df_a, df_b)asks across multiple frames and relates them. Ask for a plot and you get one. - An experimental semantic layer.
pai.create()saves a dataset with a path, a description, and typed, described columns, so the model reads business meaning rather than guessing from headers. PandasAI marks the semantic layer as experimental and aimed at advanced users. - Data beyond files. CSV and Excel load directly; a
sqlextension covers SQL, PostgreSQL, MySQL, CockroachDB, and Microsoft SQL Server. Snowflake, Databricks, and the other cloud connectors sit in the enterprise-licensed extensions. - Model-agnostic. Install
pandasai-litellmfor a unified interface to OpenAI, Anthropic, Google and others, orpandasai-openaifor OpenAI and Azure OpenAI directly, then set it once withpai.config.set(). - A real sandbox, not a promise.
pandasai-dockerruns generated code in an isolated Docker container that operates entirely offline, with strict resource limits and filesystem isolation. - An Agent for multi-turn work.
pai.chat()is for single-session exploration; theAgentclass keeps conversation state so follow-up questions like "and which one has the most deals?" resolve correctly.
In an analyst's workflow
The pattern worth adopting is to describe your columns once and then never explain them again:
import pandasai as pai
from pandasai_litellm.litellm import LiteLLM
pai.config.set({"llm": LiteLLM(model="gpt-4.1-mini", api_key="...")})
df = pai.create(
path="company/sales-data",
df=pai.read_csv("data/sales.csv"),
description="Sales data from our retail stores",
columns={
"sale_date": {"type": "datetime", "description": "Date and time of the sale"},
"quantity": {"type": "integer", "description": "Number of units sold"},
"price": {"type": "float", "description": "Price per unit, pre-discount"},
},
)
df.chat("Which product had the highest revenue last quarter?")Those column descriptions do most of the accuracy work, and they are cheaper to maintain than a prompt. Read the code it generates before you trust a number, the same discipline the checking an AI data analysis guide applies to any generated result.
WARNING
The license is not plain MIT. Everything outside pandasai/ee/ is MIT Expat; everything inside requires a PandasAI Enterprise license for production use and may not be copied, distributed, or sublicensed. GitHub's license API reports the repository as NOASSERTION for exactly this reason. Check which extension you are installing before you ship.
Good to know
PandasAI is published by Sinaptik GmbH. Version 3.0.0 is the current release on PyPI, uploaded on October 7, 2025, and requires Python 3.8 or later and below 3.12 — a narrow window worth checking against your environment. Development on the public repository has been quiet since late 2025, so treat it as a stable library rather than a fast-moving one, and pin your version.
For SQL-first work against a warehouse, Vanna is the closer open-source comparison, and the best text-to-SQL tools in 2026 sets both against the hosted options. If you want the same conversational experience without maintaining any of it, Julius is the hosted equivalent, and Claude for data analysis covers doing it with a general assistant. The best AI tools for data analysts in 2026 roundup has the full comparison.
Frequently asked questions
- What does PandasAI do?
- PandasAI turns a dataframe into something you can ask questions of. You load data with a call such as pai.read_csv, configure a language model, then call .chat() with a plain-English question. The library generates Python code, runs it, and returns the answer, which can be a value, a dataframe, or a chart. You can pass several dataframes at once and ask questions that relate them.
- Is PandasAI open source?
- Partly. Its LICENSE file says content outside the pandasai/ee directory is available under the MIT Expat license, while everything under ee/ requires a PandasAI Enterprise license for production use and may not be redistributed. Because of that split, GitHub's license API reports the repository as NOASSERTION rather than a standard SPDX identifier.
- What data sources does PandasAI support?
- CSV and Excel files load directly. A sql extension adds SQL, PostgreSQL, MySQL, CockroachDB, and Microsoft SQL Server. Cloud warehouse connectors such as Snowflake and Databricks live in the enterprise-licensed extensions, so check the license before using them in production.
- Is it safe to run PandasAI on untrusted input?
- Not without the sandbox. PandasAI executes Python that a language model wrote, so a user who can phrase the question can influence the code. The pandasai-docker package runs that code in an isolated Docker container that operates offline with resource limits and filesystem isolation. Use it for anything user-facing.
Related
- VannaAn MIT-licensed Python framework for text-to-SQL: a user-aware agent that learns from successful queries and streams tables, charts, and summaries back.
- Text-to-SQLText-to-SQL is turning a plain-language question into a SQL query a database can run, using a model grounded in your schema, documentation, and past queries.
- The Best Text-to-SQL Tools in 2026Text-to-SQL tools compared on how they ground the model in your schema, what accuracy really means, read-only safety, deployment, licensing, and pricing model.
- Claude for Data Analysis: The Complete 2026 GuideThe four surfaces where Claude touches data, what the code execution sandbox really is, how an AI analysis fails silently, and the checks that catch it.
- The Best AI Tools for Data Analysts in 2026The AI tools data analysts actually use in 2026: assistants that run code, spreadsheet add-ins, notebooks, text-to-SQL, and agents in the terminal.
- JuliusA chat-first AI data analyst: upload a spreadsheet or connect a warehouse, ask in plain English, and get charts, code, and shareable exports back.
- Code Execution (Code Interpreter)Code execution lets an AI assistant write and run real code in a sandbox, so numbers, files, and charts come from a computation rather than an estimate.