pandasai


Namepandasai JSON
Version 3.0.0 PyPI version JSON
download
home_pageNone
SummaryChat with your database (SQL, CSV, pandas, mongodb, noSQL, etc). PandasAI makes data analysis conversational using LLMs (GPT 3.5 / 4, Anthropic, VertexAI) and RAG.
upload_time2025-10-07 08:22:56
maintainerNone
docs_urlNone
authorGabriele Venturi
requires_python<3.12,>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ![PandasAI](assets/logo.png)

[![Release](https://img.shields.io/pypi/v/pandasai?label=Release&style=flat-square)](https://pypi.org/project/pandasai/)
[![CI](https://github.com/sinaptik-ai/pandas-ai/actions/workflows/ci-core.yml/badge.svg)](https://github.com/sinaptik-ai/pandas-ai/actions/workflows/ci-core.yml/badge.svg)
[![CD](https://github.com/sinaptik-ai/pandas-ai/actions/workflows/cd.yml/badge.svg)](https://github.com/sinaptik-ai/pandas-ai/actions/workflows/cd.yml/badge.svg)
[![Coverage](https://codecov.io/gh/sinaptik-ai/pandas-ai/branch/main/graph/badge.svg)](https://codecov.io/gh/sinaptik-ai/pandas-ai)
[![Discord](https://dcbadge.vercel.app/api/server/kF7FqH2FwS?style=flat&compact=true)](https://discord.gg/KYKj9F2FRH)
[![Downloads](https://static.pepy.tech/badge/pandasai)](https://pepy.tech/project/pandasai) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1ZnO-njhL7TBOYPZaqvMvGtsjckZKrv2E?usp=sharing)

PandasAI is a Python library that makes it easy to ask questions to your data in natural language. It helps non-technical users to interact with their data in a more natural way, and it helps technical users to save time, and effort when working with data.

# 🔧 Getting started

You can find the full documentation for PandasAI [here](https://docs.pandas-ai.com/).


## 📚 Using the library

### Python Requirements

Python version `3.8+ <=3.11`

### 📦 Installation

You can install the PandasAI library using pip or poetry.

With pip:

```bash
pip install pandasai
pip install pandasai-litellm
```

With poetry:

```bash
poetry add pandasai
poetry add pandasai-litellm
```

### 💻 Usage

#### Ask questions

```python
import pandasai as pai
from pandasai_litellm.litellm import LiteLLM

# Initialize LiteLLM with your OpenAI model
llm = LiteLLM(model="gpt-4.1-mini", api_key="YOUR_OPENAI_API_KEY")

# Configure PandasAI to use this LLM
pai.config.set({
    "llm": llm
})

# Load your data
df = pai.read_csv("data/companies.csv")

response = df.chat("What is the average revenue by region?")
print(response)
```

---

Or you can ask more complex questions:

```python
df.chat(
    "What is the total sales for the top 3 countries by sales?"
)
```

```
The total sales for the top 3 countries by sales is 16500.
```

#### Visualize charts

You can also ask PandasAI to generate charts for you:

```python
df.chat(
    "Plot the histogram of countries showing for each one the gd. Use different colors for each bar",
)
```

![Chart](assets/histogram-chart.png?raw=true)

#### Multiple DataFrames

You can also pass in multiple dataframes to PandasAI and ask questions relating them.

```python
import pandasai as pai
from pandasai_litellm.litellm import LiteLLM

# Initialize LiteLLM with your OpenAI model
llm = LiteLLM(model="gpt-4.1-mini", api_key="YOUR_OPENAI_API_KEY")

# Configure PandasAI to use this LLM
pai.config.set({
    "llm": llm
})

employees_data = {
    'EmployeeID': [1, 2, 3, 4, 5],
    'Name': ['John', 'Emma', 'Liam', 'Olivia', 'William'],
    'Department': ['HR', 'Sales', 'IT', 'Marketing', 'Finance']
}

salaries_data = {
    'EmployeeID': [1, 2, 3, 4, 5],
    'Salary': [5000, 6000, 4500, 7000, 5500]
}

employees_df = pai.DataFrame(employees_data)
salaries_df = pai.DataFrame(salaries_data)


pai.chat("Who gets paid the most?", employees_df, salaries_df)
```

```
Olivia gets paid the most.
```

#### Docker Sandbox

You can run PandasAI in a Docker sandbox, providing a secure, isolated environment to execute code safely and mitigate the risk of malicious attacks.

##### Python Requirements

```bash
pip install "pandasai-docker"
```

##### Usage

```python
import pandasai as pai
from pandasai_docker import DockerSandbox
from pandasai_litellm.litellm import LiteLLM

# Initialize LiteLLM with your OpenAI model
llm = LiteLLM(model="gpt-4.1-mini", api_key="YOUR_OPENAI_API_KEY")

# Configure PandasAI to use this LLM
pai.config.set({
    "llm": llm
})

# Initialize the sandbox
sandbox = DockerSandbox()
sandbox.start()

employees_data = {
    'EmployeeID': [1, 2, 3, 4, 5],
    'Name': ['John', 'Emma', 'Liam', 'Olivia', 'William'],
    'Department': ['HR', 'Sales', 'IT', 'Marketing', 'Finance']
}

salaries_data = {
    'EmployeeID': [1, 2, 3, 4, 5],
    'Salary': [5000, 6000, 4500, 7000, 5500]
}

employees_df = pai.DataFrame(employees_data)
salaries_df = pai.DataFrame(salaries_data)

pai.chat("Who gets paid the most?", employees_df, salaries_df, sandbox=sandbox)

# Don't forget to stop the sandbox when done
sandbox.stop()
```

```
Olivia gets paid the most.
```

You can find more examples in the [examples](examples) directory.

## 📜 License

PandasAI is available under the MIT expat license, except for the `pandasai/ee` directory of this repository, which has its [license here](https://github.com/sinaptik-ai/pandas-ai/blob/main/ee/LICENSE).

If you are interested in managed PandasAI Cloud or self-hosted Enterprise Offering, [contact us](https://pandas-ai.com).

## Resources

- [Docs](https://docs.pandas-ai.com/) for comprehensive documentation
- [Examples](examples) for example notebooks
- [Discord](https://discord.gg/KYKj9F2FRH) for discussion with the community and PandasAI team

## 🤝 Contributing

Contributions are welcome! Please check the outstanding issues and feel free to open a pull request.
For more information, please check out the [contributing guidelines](CONTRIBUTING.md).

### Thank you!

[![Contributors](https://contrib.rocks/image?repo=sinaptik-ai/pandas-ai)](https://github.com/sinaptik-ai/pandas-ai/graphs/contributors)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pandasai",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.12,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Gabriele Venturi",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/fb/28/6e98c3c5ece389e223103efcc540708800e0db8c3764d38fb596dfd729fb/pandasai-3.0.0.tar.gz",
    "platform": null,
    "description": "# ![PandasAI](assets/logo.png)\n\n[![Release](https://img.shields.io/pypi/v/pandasai?label=Release&style=flat-square)](https://pypi.org/project/pandasai/)\n[![CI](https://github.com/sinaptik-ai/pandas-ai/actions/workflows/ci-core.yml/badge.svg)](https://github.com/sinaptik-ai/pandas-ai/actions/workflows/ci-core.yml/badge.svg)\n[![CD](https://github.com/sinaptik-ai/pandas-ai/actions/workflows/cd.yml/badge.svg)](https://github.com/sinaptik-ai/pandas-ai/actions/workflows/cd.yml/badge.svg)\n[![Coverage](https://codecov.io/gh/sinaptik-ai/pandas-ai/branch/main/graph/badge.svg)](https://codecov.io/gh/sinaptik-ai/pandas-ai)\n[![Discord](https://dcbadge.vercel.app/api/server/kF7FqH2FwS?style=flat&compact=true)](https://discord.gg/KYKj9F2FRH)\n[![Downloads](https://static.pepy.tech/badge/pandasai)](https://pepy.tech/project/pandasai) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1ZnO-njhL7TBOYPZaqvMvGtsjckZKrv2E?usp=sharing)\n\nPandasAI is a Python library that makes it easy to ask questions to your data in natural language. It helps non-technical users to interact with their data in a more natural way, and it helps technical users to save time, and effort when working with data.\n\n# \ud83d\udd27 Getting started\n\nYou can find the full documentation for PandasAI [here](https://docs.pandas-ai.com/).\n\n\n## \ud83d\udcda Using the library\n\n### Python Requirements\n\nPython version `3.8+ <=3.11`\n\n### \ud83d\udce6 Installation\n\nYou can install the PandasAI library using pip or poetry.\n\nWith pip:\n\n```bash\npip install pandasai\npip install pandasai-litellm\n```\n\nWith poetry:\n\n```bash\npoetry add pandasai\npoetry add pandasai-litellm\n```\n\n### \ud83d\udcbb Usage\n\n#### Ask questions\n\n```python\nimport pandasai as pai\nfrom pandasai_litellm.litellm import LiteLLM\n\n# Initialize LiteLLM with your OpenAI model\nllm = LiteLLM(model=\"gpt-4.1-mini\", api_key=\"YOUR_OPENAI_API_KEY\")\n\n# Configure PandasAI to use this LLM\npai.config.set({\n    \"llm\": llm\n})\n\n# Load your data\ndf = pai.read_csv(\"data/companies.csv\")\n\nresponse = df.chat(\"What is the average revenue by region?\")\nprint(response)\n```\n\n---\n\nOr you can ask more complex questions:\n\n```python\ndf.chat(\n    \"What is the total sales for the top 3 countries by sales?\"\n)\n```\n\n```\nThe total sales for the top 3 countries by sales is 16500.\n```\n\n#### Visualize charts\n\nYou can also ask PandasAI to generate charts for you:\n\n```python\ndf.chat(\n    \"Plot the histogram of countries showing for each one the gd. Use different colors for each bar\",\n)\n```\n\n![Chart](assets/histogram-chart.png?raw=true)\n\n#### Multiple DataFrames\n\nYou can also pass in multiple dataframes to PandasAI and ask questions relating them.\n\n```python\nimport pandasai as pai\nfrom pandasai_litellm.litellm import LiteLLM\n\n# Initialize LiteLLM with your OpenAI model\nllm = LiteLLM(model=\"gpt-4.1-mini\", api_key=\"YOUR_OPENAI_API_KEY\")\n\n# Configure PandasAI to use this LLM\npai.config.set({\n    \"llm\": llm\n})\n\nemployees_data = {\n    'EmployeeID': [1, 2, 3, 4, 5],\n    'Name': ['John', 'Emma', 'Liam', 'Olivia', 'William'],\n    'Department': ['HR', 'Sales', 'IT', 'Marketing', 'Finance']\n}\n\nsalaries_data = {\n    'EmployeeID': [1, 2, 3, 4, 5],\n    'Salary': [5000, 6000, 4500, 7000, 5500]\n}\n\nemployees_df = pai.DataFrame(employees_data)\nsalaries_df = pai.DataFrame(salaries_data)\n\n\npai.chat(\"Who gets paid the most?\", employees_df, salaries_df)\n```\n\n```\nOlivia gets paid the most.\n```\n\n#### Docker Sandbox\n\nYou can run PandasAI in a Docker sandbox, providing a secure, isolated environment to execute code safely and mitigate the risk of malicious attacks.\n\n##### Python Requirements\n\n```bash\npip install \"pandasai-docker\"\n```\n\n##### Usage\n\n```python\nimport pandasai as pai\nfrom pandasai_docker import DockerSandbox\nfrom pandasai_litellm.litellm import LiteLLM\n\n# Initialize LiteLLM with your OpenAI model\nllm = LiteLLM(model=\"gpt-4.1-mini\", api_key=\"YOUR_OPENAI_API_KEY\")\n\n# Configure PandasAI to use this LLM\npai.config.set({\n    \"llm\": llm\n})\n\n# Initialize the sandbox\nsandbox = DockerSandbox()\nsandbox.start()\n\nemployees_data = {\n    'EmployeeID': [1, 2, 3, 4, 5],\n    'Name': ['John', 'Emma', 'Liam', 'Olivia', 'William'],\n    'Department': ['HR', 'Sales', 'IT', 'Marketing', 'Finance']\n}\n\nsalaries_data = {\n    'EmployeeID': [1, 2, 3, 4, 5],\n    'Salary': [5000, 6000, 4500, 7000, 5500]\n}\n\nemployees_df = pai.DataFrame(employees_data)\nsalaries_df = pai.DataFrame(salaries_data)\n\npai.chat(\"Who gets paid the most?\", employees_df, salaries_df, sandbox=sandbox)\n\n# Don't forget to stop the sandbox when done\nsandbox.stop()\n```\n\n```\nOlivia gets paid the most.\n```\n\nYou can find more examples in the [examples](examples) directory.\n\n## \ud83d\udcdc License\n\nPandasAI is available under the MIT expat license, except for the `pandasai/ee` directory of this repository, which has its [license here](https://github.com/sinaptik-ai/pandas-ai/blob/main/ee/LICENSE).\n\nIf you are interested in managed PandasAI Cloud or self-hosted Enterprise Offering, [contact us](https://pandas-ai.com).\n\n## Resources\n\n- [Docs](https://docs.pandas-ai.com/) for comprehensive documentation\n- [Examples](examples) for example notebooks\n- [Discord](https://discord.gg/KYKj9F2FRH) for discussion with the community and PandasAI team\n\n## \ud83e\udd1d Contributing\n\nContributions are welcome! Please check the outstanding issues and feel free to open a pull request.\nFor more information, please check out the [contributing guidelines](CONTRIBUTING.md).\n\n### Thank you!\n\n[![Contributors](https://contrib.rocks/image?repo=sinaptik-ai/pandas-ai)](https://github.com/sinaptik-ai/pandas-ai/graphs/contributors)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Chat with your database (SQL, CSV, pandas, mongodb, noSQL, etc). PandasAI makes data analysis conversational using LLMs (GPT 3.5 / 4, Anthropic, VertexAI) and RAG.",
    "version": "3.0.0",
    "project_urls": {
        "Documentation": "https://docs.pandas-ai.com/",
        "Repository": "https://github.com/sinaptik-ai/pandas-ai"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7acf1dba25c504810d946aacd6e4b2fb9c4a415a88d1850a8a4788a2c8599e24",
                "md5": "bbde9a93f8c4b40a87b084c86a62f222",
                "sha256": "1d37629f2450dfe25b47b437f581ce7ca88c4ea321f9a9c8c1eaf4e82ed52ebf"
            },
            "downloads": -1,
            "filename": "pandasai-3.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bbde9a93f8c4b40a87b084c86a62f222",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.12,>=3.8",
            "size": 83162,
            "upload_time": "2025-10-07T08:22:55",
            "upload_time_iso_8601": "2025-10-07T08:22:55.304430Z",
            "url": "https://files.pythonhosted.org/packages/7a/cf/1dba25c504810d946aacd6e4b2fb9c4a415a88d1850a8a4788a2c8599e24/pandasai-3.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fb286e98c3c5ece389e223103efcc540708800e0db8c3764d38fb596dfd729fb",
                "md5": "e6b4c2480ee528f9c3974d8bd24a7736",
                "sha256": "f1bac4e98085dad4cc5072a86287143bccf7b651b8b0459a82bdc20a93f427c9"
            },
            "downloads": -1,
            "filename": "pandasai-3.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e6b4c2480ee528f9c3974d8bd24a7736",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.12,>=3.8",
            "size": 55278,
            "upload_time": "2025-10-07T08:22:56",
            "upload_time_iso_8601": "2025-10-07T08:22:56.522938Z",
            "url": "https://files.pythonhosted.org/packages/fb/28/6e98c3c5ece389e223103efcc540708800e0db8c3764d38fb596dfd729fb/pandasai-3.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-07 08:22:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sinaptik-ai",
    "github_project": "pandas-ai",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pandasai"
}
        
Elapsed time: 1.49234s