Name: Pandas-ai ()
Type: Developer and Database Interaction Model
Introduction: By using Large Language Models (LLMs) and Retrieve-Based Generating Models (RAG), developers ‘interactions with databases or data lakes (such as SQL, CSV, and parquet formats) are as simple as chatting, greatly simplifying the process of data analysis.
PandasAI is an open source Python library designed to add Generative AI capabilities to Pandas, a popular data analysis and processing tool. It enables users to interact with data through natural language queries, making data analysis more interactive and intuitive.citeturn0search0
Main functions:
-
Natural language query: Users can interact with data using a human-like query language without having to write complex code.citeturn0search5
-
Seamless integration: PandasAI is closely integrated with Pandas, retaining all Pandas functions while adding AI-driven query capabilities.citeturn0search0
-
Multi-platform support: PandasAI can be used in Jupyter notebooks, Streamlit applications and other environments, providing a flexible experience.citeturn0search0
Installation and use:
-
Installation: Install PandasAI via pip using the following command:
pip install pandasai -
Basic usage: After installation, you can use PandasAI by following these steps:
import pandas as pd from pandasai import SmartDataframe from pandasai.llm import OpenAI #Create a sample DataFrame df = pd.DataFrame({ "Country": ["United States", "United Kingdom", "France", "Germany", "Italy", "Spain", "Canada", "Australia", "Japan", "China"], "Income": [5000, 3200, 2900, 4100, 2300, 2100, 2500, 2600, 4500, 7000] }) #Set OpenAI API key llm = OpenAI(api_token="Your-openai-api-key") #Create a SmartDataframe object pandas_ai = SmartDataframe(df, config={"llm": llm}) #Query data using natural language response = pandas_ai.ask("Which country has the highest income? ") print(response)The above code will be exported to the countries with the highest incomes.
Notes:
-
API key: Using PandasAI requires setting OpenAI’s API key. You can pass the key directly to
OpenAIObject, or set environment variablesOPENAI_API_KEYto achieve it.citeturn0search3 -
Environmental requirements: PandasAI requires Python version 3.8 and above.citeturn0search0
Resources and Links:
-
PandasAI GitHub repository: citeturn0search0
-
PandasAI official website: citeturn0search5
The emergence of PandasAI has made data analysis more user-friendly and intuitive, lowered the threshold for non-technical users to interact with data, and also saved time and energy for technical users.
GitHub:https://github.com/sinaptik-ai/pandas-ai
Oil tubing: