- Notifications
You must be signed in to change notification settings - Fork2.3k
Chat with your database or your datalake (SQL, CSV, parquet). PandasAI makes data analysis conversational using LLMs and RAG.
License
sinaptik-ai/pandas-ai
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
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.
You can find the full documentation for PandasAIhere.
Python version3.8+ <=3.11
You can install the PandasAI library using pip or poetry.
With pip:
pip install pandasaipip install pandasai-litellm
With poetry:
poetry add pandasaipoetry add pandasai-litellm
importpandasaiaspaifrompandasai_litellm.litellmimportLiteLLM# Initialize LiteLLM with your OpenAI modelllm=LiteLLM(model="gpt-4.1-mini",api_key="YOUR_OPENAI_API_KEY")# Configure PandasAI to use this LLMpai.config.set({"llm":llm})# Load your datadf=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:
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.You can also ask PandasAI to generate charts for you:
df.chat("Plot the histogram of countries showing for each one the gdp. Use different colors for each bar",)
You can also pass in multiple dataframes to PandasAI and ask questions relating them.
importpandasaiaspaifrompandasai_litellm.litellmimportLiteLLM# Initialize LiteLLM with your OpenAI modelllm=LiteLLM(model="gpt-4.1-mini",api_key="YOUR_OPENAI_API_KEY")# Configure PandasAI to use this LLMpai.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.You can run PandasAI in a Docker sandbox, providing a secure, isolated environment to execute code safely and mitigate the risk of malicious attacks.
pip install"pandasai-docker"importpandasaiaspaifrompandasai_dockerimportDockerSandboxfrompandasai_litellm.litellmimportLiteLLM# Initialize LiteLLM with your OpenAI modelllm=LiteLLM(model="gpt-4.1-mini",api_key="YOUR_OPENAI_API_KEY")# Configure PandasAI to use this LLMpai.config.set({"llm":llm})# Initialize the sandboxsandbox=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 donesandbox.stop()
Olivia gets paid the most.You can find more examples in theexamples directory.
PandasAI is available under the MIT expat license, except for thepandasai/ee directory of this repository, which has itslicense here.
If you are interested in managed PandasAI Cloud or self-hosted Enterprise Offering,contact us.
- Docs for comprehensive documentation
- Examples for example notebooks
- Discord for discussion with the community and PandasAI team
Contributions are welcome! Please check the outstanding issues and feel free to open a pull request.For more information, please check out thecontributing guidelines.
About
Chat with your database or your datalake (SQL, CSV, parquet). PandasAI makes data analysis conversational using LLMs and RAG.
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.

