Skip to main content

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.

Project description

PandasAI

Release CI CD Coverage Discord Downloads License: MIT Open in Colab

PandasAI is a Python platform 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.

You can either decide to use PandasAI in your Jupyter notebooks, Streamlit apps, or use the client and server architecture from the repo.

📚 Using the library

Python Requirements

Python version 3.8+ <3.12

📦 Installation

You can install the PandasAI library using pip or poetry.

With pip:

pip install "pandasai>=3.0.0b2"

With poetry:

poetry add "pandasai>=3.0.0b2"

💻 Usage

Ask questions

import pandasai as pai
from pandasai_openai.openai import OpenAI

llm = OpenAI("OPEN_AI_API_KEY")

pai.config.set({
    "llm": llm
})

# Sample DataFrame
df = pai.DataFrame({
    "country": ["United States", "United Kingdom", "France", "Germany", "Italy", "Spain", "Canada", "Australia", "Japan", "China"],
    "revenue": [5000, 3200, 2900, 4100, 2300, 2100, 2500, 2600, 4500, 7000]
})

df.chat('Which are the top 5 countries by sales?')
China, United States, Japan, Germany, Australia

Or you can ask more complex questions:

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:

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

Chart

Multiple DataFrames

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

import pandasai as pai
from pandasai_openai.openai import OpenAI

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]
}

llm = OpenAI("OPEN_AI_API_KEY")

pai.config.set({
    "llm": llm
})

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
pip install "pandasai-docker"
Usage
import pandasai as pai
from pandasai_docker import DockerSandbox
from pandasai_openai.openai import OpenAI

# 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]
}

llm = OpenAI("OPEN_AI_API_KEY")

pai.config.set({
    "llm": llm
})

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 directory.

📜 License

PandasAI is available under the MIT expat license, except for the pandasai/ee directory of this repository, which has its license here.

If you are interested in managed PandasAI Cloud or self-hosted Enterprise Offering, contact us.

Resources

Beta Notice
Release v3 is currently in beta. The following documentation and examples reflect the features and functionality in progress and may change before the final release.

  • Docs for comprehensive documentation
  • Examples for example notebooks
  • Discord 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.

Thank you!

Contributors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jcloudai-1.0.5.tar.gz (52.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jcloudai-1.0.5-py3-none-any.whl (78.7 kB view details)

Uploaded Python 3

File details

Details for the file jcloudai-1.0.5.tar.gz.

File metadata

  • Download URL: jcloudai-1.0.5.tar.gz
  • Upload date:
  • Size: 52.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.5 Darwin/24.1.0

File hashes

Hashes for jcloudai-1.0.5.tar.gz
Algorithm Hash digest
SHA256 d7cea8befffc2574578a4642f09ecceb2899d802650db57f9d2692d84520a92c
MD5 88794e7d58d564e53b96797b06d4e22c
BLAKE2b-256 6f0d8ca310e32e9f4d761b73eeeedb8285dffa275c342d30521d3aefdcc4343b

See more details on using hashes here.

File details

Details for the file jcloudai-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: jcloudai-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 78.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.13.5 Darwin/24.1.0

File hashes

Hashes for jcloudai-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 06e5262c41293af97281bd703a99e679757f48fc49949da1d413696eba0e5dc0
MD5 e7bfdf4d4015c74ec5a2d330c582d334
BLAKE2b-256 5a536692582b68bcd6b50967efe24bc09c343f15e58ca7249577d732c16cb909

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page