Conversational Pandas Dataframes
Project description
pandas-llm
pandas-llm is a lightweight Python library that extends pandas to allow querying datasets using OpenAI prompts. This powerful tool leverages the natural language processing capabilities of OpenAI to offer intuitive, language-based querying of your pandas dataframes.
Installation
Install pandas-llm using pip:
pip install pandas_llm
Features
- Query pandas dataframes using natural language prompts.
- Leverage the power of OpenAI's language models in your data analysis.
- Seamless integration with existing pandas functions.
Usage
Here's a quick example of how to use pandas-llm:
import os
import pandas as pd
from pandas_llm import PandasLLM
# your key
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
# Data
# Please note that these names, ages, and donations are randomly generated
# and do not correspond to real individuals or their donations.
data = [('John Doe', 25, 50),
('Jane Smith', 38, 70),
('Alex Johnson', 45, 80),
('Jessica Brown', 60, 40),
('Michael Davis', 22, 90),
('Emily Wilson', 30, 60),
('Daniel Taylor', 35, 75),
('Sophia Moore', 40, 85),
('David Thomas', 50, 65),
('Olivia Jackson', 29, 55)]
df = pd.DataFrame(data, columns=['name', 'age', 'donation'])
conv_df = PandasLLM(data=df, config={ "openai_api_key":OPENAI_API_KEY})
result = conv_df.prompt("What is the average donation of people older than 30 who donated more than $50?")
print(f"Result ({type(result)}):\n {result}")
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.
License
MIT
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
pandas_llm-0.0.2.tar.gz
(7.4 kB
view hashes)
Built Distribution
Close
Hashes for pandas_llm-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b02e6294397fef155ca6ce9f751be0325707bf8e9eb53841e7e0c192c67edefe |
|
MD5 | a834f5c13183fbd08a623d0e41d50a6b |
|
BLAKE2b-256 | 683aed96c7eb483cfec6ca0c69d4478c261a01c1bfe897fba6cac5813c5acb25 |