Skip to main content

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)

Uploaded Source

Built Distribution

pandas_llm-0.0.2-py3-none-any.whl (8.8 kB view hashes)

Uploaded Python 3

Supported by

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