English to pandas: how the magic works
`import pandas as pd; from pandasai import SmartDataframe; df = pd.read_csv('traffic.csv'); sdf = SmartDataframe(df); sdf.chat('which review category has the highest average time on page?')`. Pandas AI sends the dataframe schema (column names, types, sample values) and your question to an LLM. The LLM generates pandas code, Pandas AI executes it in a sandbox, and returns the result. For charting: `sdf.chat('plot daily page views as a line chart')` generates matplotlib code and returns the chart image.
Real accuracy on complex queries
Simple queries (filter, group, aggregate): 95% accurate. 'Show me top 5 categories by total page views' works every time. Medium queries (joins, window functions): 80% accurate. 'Show me the 7-day rolling average of page views per category' works most of the time but sometimes forgets to handle missing dates. Complex queries (multi-step, conditional): 60% accurate. 'Find categories where the trend changed direction in the last 2 weeks' fails often because the LLM generates code that is syntactically correct but logically wrong.
The code preview feature builds trust
Before executing, Pandas AI shows the generated pandas code. This is the feature that makes it usable in production: you see exactly what it plans to run and can catch errors before execution. For the 20% of queries where the code is wrong, you see the mistake in the preview, edit the code manually, and run again. This hybrid approach (AI generates, human reviews) is the right UX for data analysis tools.
Privacy: where your data goes
By default, Pandas AI sends your dataframe schema and your question to OpenAI's API. Your actual data rows are NOT sent: only column names, types, and a 5-row sample. This means sensitive data stays on your machine. For fully local execution, Pandas AI supports Ollama and local models via LangChain. With a local DeepSeek model, query accuracy drops from 95% to 75% for simple queries and 60% to 40% for complex ones.
Pandas AI vs ChatGPT data analysis vs writing pandas yourself
Pandas AI: fastest for repetitive pandas queries, code preview, charting built-in. ChatGPT data analysis (Plus feature): better at complex reasoning, can handle follow-up questions, requires uploading your data to OpenAI. Writing pandas yourself: most control, most time. Use Pandas AI for daily analysis, ChatGPT for complex analysis, and write pandas yourself when the AI-generated code consistently fails.