Skip to main content

Chat with your database (SQL, CSV, pandas, polars, 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.

🚀 Deploying PandasAI

PandasAI can be used in a variety of ways. You can easily use it in your Jupyter notebooks or streamlit apps, or you can deploy it as a REST API such as with FastAPI or Flask.

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

🔧 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 platform

PandasAI platform

📦 Installation

PandasAI platform is uses a dockerized client-server architecture. You will need to have Docker installed in your machine.

git clone https://github.com/sinaptik-ai/pandas-ai/
cd pandas-ai
docker-compose build

🚀 Running the platform

Once you have built the platform, you can run it with:

docker-compose up

This will start the client and server, and you can access the client at http://localhost:3000.

📚 Using the library

📦 Installation

You can install the PandasAI library using pip or poetry.

With pip:

pip install pandasai

With poetry:

poetry add pandasai

🔍 Demo

Try out the PandasAI library yourself in your browser:

Open in Colab

💻 Usage

Ask questions

import os
import pandas as pd
from pandasai import Agent

# Sample DataFrame
sales_by_country = pd.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]
})

# By default, unless you choose a different LLM, it will use BambooLLM.
# You can get your free API key signing up at https://pandabi.ai (you can also configure it in your .env file)
os.environ["PANDASAI_API_KEY"] = "YOUR_API_KEY"

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

Or you can ask more complex questions:

agent.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:

agent.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 os
import pandas as pd
from pandasai import Agent

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 = pd.DataFrame(employees_data)
salaries_df = pd.DataFrame(salaries_data)

# By default, unless you choose a different LLM, it will use BambooLLM.
# You can get your free API key signing up at https://pandabi.ai (you can also configure it in your .env file)
os.environ["PANDASAI_API_KEY"] = "YOUR_API_KEY"

agent = Agent([employees_df, salaries_df])
agent.chat("Who gets paid the most?")
Olivia gets paid the most.

You can find more examples in the examples directory.

🔒 Privacy & Security

In order to generate the Python code to run, we take some random samples from the dataframe, we randomize it (using random generation for sensitive data and shuffling for non-sensitive data) and send just the randomized head to the LLM.

If you want to enforce further your privacy you can instantiate PandasAI with enforce_privacy = True which will not send the head (but just column names) to the LLM.

📜 License

PandasAI is available under the MIT expat license, except for the pandasai/ee directory (which has it's license here if applicable.

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

Resources

  • 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


Release history Release notifications | RSS feed

Download files

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

Source Distribution

pandasai-2.3.0.tar.gz (114.9 kB view details)

Uploaded Source

Built Distribution

pandasai-2.3.0-py3-none-any.whl (186.0 kB view details)

Uploaded Python 3

File details

Details for the file pandasai-2.3.0.tar.gz.

File metadata

  • Download URL: pandasai-2.3.0.tar.gz
  • Upload date:
  • Size: 114.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.0 Linux/6.5.0-1025-azure

File hashes

Hashes for pandasai-2.3.0.tar.gz
Algorithm Hash digest
SHA256 fb58d2c55dd53988dcf6207ea196ee52eb2c2262fbd389e1ecddaed3a6093ecf
MD5 f15933da1dd9f9fd9a9b158a2b16e9f5
BLAKE2b-256 8cb6434c9ff142617e8dcd6964e8711572d935d6307ca9e29b1204de3796facf

See more details on using hashes here.

File details

Details for the file pandasai-2.3.0-py3-none-any.whl.

File metadata

  • Download URL: pandasai-2.3.0-py3-none-any.whl
  • Upload date:
  • Size: 186.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.11.0 Linux/6.5.0-1025-azure

File hashes

Hashes for pandasai-2.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 15a586e5b90e16ca685b31d7eb2dcff2783c97feac9e0e4e1090b2b16d931d3e
MD5 8df1147302b4dc66e937e6ed31882cd6
BLAKE2b-256 71ca0bcaf20b4cb305f4cfbca7be09cf2b06d09cbabbfe7d7ea0035d3322b214

See more details on using hashes here.

Supported by

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