LogoAIAny
Icon for item

PandasAI

PandasAI is an open-source Python library that enables conversational data analysis by letting users query and interact with tabular data (pandas DataFrames, CSV, parquet, SQL) using natural language. It integrates with large language models (LLMs) to generate analysis, visualizations, and code, supports multiple DataFrames and a Docker sandbox for safe execution, and is distributed under the MIT license.

Introduction

Overview

PandasAI is a Python library that brings conversational capabilities to tabular data analysis. By connecting pandas DataFrames to a large language model (LLM), PandasAI allows users to ask natural-language questions about their data, get analysis summaries, request plots, and produce pandas code snippets or direct answers — all through a chat-like interface.

Key features
  • Conversational queries: Ask natural-language questions about your DataFrame (e.g., "What is the average revenue by region?") and receive direct answers or generated pandas code.
  • Multi-DataFrame support: Query and relate multiple DataFrames in a single conversational session.
  • Visualization generation: Request charts (histograms, bar plots, scatter plots, etc.) in plain language and receive generated visualizations.
  • LLM integration: Works with various LLM backends (examples in the repo show integration patterns like LiteLLM and OpenAI models). This allows leveraging models for reasoning, summarization, and code generation.
  • Docker sandbox: Optional sandboxed environment to run generated code safely, reducing the risk of executing untrusted code on the host machine.
  • RAG (Retrieval-Augmented Generation) compatibility: Designed to be used in workflows where external context or retrieval improves answers to data questions.
  • Low barrier to entry: Aimed at both non-technical users (natural-language access to data) and technical users (speeding up exploration and prototyping).
Getting started (summary)
  1. Install: pip install pandasai (and optional LLM adapters like pandasai-litellm).
  2. Configure an LLM backend and API key in the library config.
  3. Load your data into a pandas DataFrame and call df.chat("Your question") to interact.

Example:

import pandasai as pai
from pandasai_litellm.litellm import LiteLLM
 
llm = LiteLLM(model="gpt-4.1-mini", api_key="YOUR_OPENAI_API_KEY")
 
pai.config.set({"llm": llm})
df = pai.read_csv("data/companies.csv")
response = df.chat("What is the average revenue by region?")
print(response)
Use cases
  • Business analysts who want to query datasets without writing pandas code.
  • Data scientists who want to prototype analyses quickly or generate code snippets for repetitive tasks.
  • Teams building data-driven chat interfaces or LLM-powered analytics products.
Governance & license

PandasAI is published under the MIT license. The repository provides documentation, examples, and a Discord community for discussion.

The project provides docs at the official site and examples in the GitHub repository. It includes CI/CD badges, tests coverage, and installation instructions in its README.

Information

  • Websitegithub.com
  • Authorssinaptik-ai (GitHub organization)
  • Published date2023/04/22