Skip to main content

Conversational Pandas Dataframes

Project description

pandas-LLM

Introduction

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.

Key Features

  • Natural Language Querying: With pandas-llm, you can execute complex Pandas queries using natural language prompts. Instead of writing code, you can express your query in plain language and obtain the desired results.

  • Seamless Integration: The library seamlessly integrates with your existing Pandas workflow. You can continue using normal Pandas functions and syntax while leveraging the added capability of natural language queries.

  • Efficiency and Performance: pandas-LLM is designed to deliver efficient and performant querying capabilities. It uses OpenAI's language model to process queries quickly and accurately, providing rapid insights from your data.

  • Flexible and Expressive: Whether you need to filter, aggregate, sort, or transform your data, pandas-LLM allows you to express your requirements flexibly and expressively. You can perform complex operations on your dataframes with ease using human-readable language.

  • Intelligent Results: The library returns the results of your queries in a concise and understandable format. You can extract valuable insights from your data without complex code or manual analysis.

With pandas-llm, you can unlock the power of natural language querying and effortlessly execute complex pandas queries. Let the library handle the intricacies of data manipulation while you focus on gaining insights and making data-driven decisions.

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

# 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, llm_api_key = os.environ.get("OPENAI_API_KEY"))
result = conv_df.prompt("What is the average donation of people older than 40 who donated more than $50?")
code = conv_df.code_block

print(f"Executing the following expression of type {type(result)}:\n{code}\n\nResult is:\n {result}\n")
# Executing the following expression of type <class 'numpy.float64'>:
# result = df.loc[(df['age'] > 40) & (df['donation'] > 50), 'donation'].mean()

# Result is:
#  72.5

There is also a chatbot available in the repository using the same dataset. Look at example-chatbot.py

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.6.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

pandas_llm-0.0.6-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file pandas_llm-0.0.6.tar.gz.

File metadata

  • Download URL: pandas_llm-0.0.6.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for pandas_llm-0.0.6.tar.gz
Algorithm Hash digest
SHA256 6822686da4a5d43b556d26502105a8dc63266635c93cd3d387404b3715d568c0
MD5 face756a185eda29ed9334f56f854145
BLAKE2b-256 944d9cec6381faaffe5b40be91fd8401b5928b938d55f076d4e1315ef3297bf1

See more details on using hashes here.

File details

Details for the file pandas_llm-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: pandas_llm-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for pandas_llm-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ea71160efbc3b423699d66e1b668a0ba2a83a9dac6cbbd51808ec7e7249b27c1
MD5 d3183c5d80473389adb380089c9d579c
BLAKE2b-256 55c5b37640485437bef52e45127388d8d4ef28cbfc8409767b3ce94944f8a23f

See more details on using hashes here.

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