Natural language interface for DataFrames using LLMs
Project description
🧠 DataWhisperer
Talk to your DataFrame. Literally.
DataWhisperer is a professional-grade Python library that enables interaction with pandas DataFrames using natural language. Powered by LLMs like OpenAI and Google Gemini, it transforms analytical questions into executable Python code. Whether you need summaries, transformations, or visualizations, DataWhisperer delivers accurate results and adapts dynamically to your data structure.
✨ No more
.groupby(),.pivot()or plotting boilerplate. Just whisper to your data.
🚀 Key Features
- 🔗 Natural Language to Python code conversion for DataFrames
- 📊 Auto-generated visualizations with Plotly
- 🛠️ Automatic error detection & self-repair with multi-step retry logic
- 🧠 Supports OpenAI, Gemini, and is extensible to Claude, LLaMA, Mistral (coming soon)
- 🔁 Smart retry strategy for broken code (
max_retries) - 🧼 Schema-driven prompt system (auto-describes your columns)
- 🧪 Modular and testable architecture
- 🧩 Plugin-ready and LLM-client agnostic (future-proof)
📦 Installation
Install from TestPyPI:
pip install -i https://test.pypi.org/simple/ datawhisperer
Or, for local development:
git clone https://github.com/JosueARz/DataWhisperer.git
cd DataWhisperer
pip install -e .
Requirements: Python 3.8+
⚡ Quick Start
from datawhisperer import DataFrameChatbot
import pandas as pd
# Load your dataset
data = pd.read_csv("sales_data.csv")
# Describe the columns
schema = {
"region": "Sales region (e.g., North, South, East, West)",
"sales": "Amount of revenue generated",
"date": "Date of the sale"
}
# Create the chatbot
bot = DataFrameChatbot(
api_key="your-api-key",
model="gpt-4", # or "gemini-1.5-flash"
dataframe=data,
schema=schema,
max_retries=3 # Number of auto-repair attempts if execution fails
)
# Ask a question
response = bot.ask_and_run("Show a bar chart of total sales per region")
# Display result
print(response.text)
response.table # Or: response.chart
🧠 What kind of questions can I ask?
- "Which region had the highest revenue in Q2?"
- "Show average sales by month."
- "Plot a heatmap of transactions by region and month."
- "How many sales were made after July 15th?"
- "Which regions had declining revenue trends over time?"
DataWhisperer will generate optimized and runnable Python code — and automatically fix it if it fails.
✅ Example Output
🔍 Input (user question):
"What are the top 3 regions by total sales?"
🧪 Output (Python code):
import pandas as pd
import plotly.express as px
# Group and sort data
top_regions = df.groupby("region")["sales"].sum().sort_values(ascending=False).head(3).reset_index()
print("Top 3 regions by total sales:")
# Display table
top_regions
📋 Output (text + table):
Top 3 regions by total sales:
| region | sales |
|---|---|
| North | 102,400.0 |
| East | 98,900.0 |
| South | 87,120.0 |
🧪 Testing the Library
pytest
pytest --cov=datawhisperer --cov-report=term-missing
Coverage Includes:
- Code generation & formatting (
PromptFactory) - Code execution & error repair (
executor.py) - Retry logic & self-healing (
fixer.py) - Chat interface orchestration (
DataFrameChatbot)
Note: Tests use fake LLM clients to avoid real API calls.
📌 Version
Current release: v0.1.4
See the CHANGELOG.md for updates.
Upcoming versions will include:
- SQL + Python-SQL modes
- Multiple LLM client support
- DuckDB, SQLite, Postgres connectors
- CLI + Streamlit interface
- Plugin hooks
📖 Documentation
Full documentation will be hosted via MkDocs in future release v1.0.0.
- Quickstart & API Reference
- Examples & Recipes
- Plugin Development Guide
📄 License
Apache License 2.0 — use it freely, contribute professionally. © 2024 JosueARz
🤝 Contributing
Pull requests are welcome. Please ensure your changes are:
- Type hinted and PEP8-compliant
- Tested with pytest
- Explained clearly in PR descriptions
🧙 Why "Whisperer"?
Because it doesn’t just chat — it understands your data.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file datawhisperer-0.1.4.tar.gz.
File metadata
- Download URL: datawhisperer-0.1.4.tar.gz
- Upload date:
- Size: 22.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8de87857965532f5ed7a91e790cf21610e7fe29ecb69fab62dd83100dced3ec0
|
|
| MD5 |
6917bcc4b1e3df430d85e170cc728822
|
|
| BLAKE2b-256 |
13cd82f34f77426fad84d7515549dd910996c5deef65070e6bfc2a79a1661ae6
|
File details
Details for the file datawhisperer-0.1.4-py3-none-any.whl.
File metadata
- Download URL: datawhisperer-0.1.4-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d36ff6722d4c4af189ba0a182b9ac51d568fbed5c8bd13a63114612219ec3db9
|
|
| MD5 |
c60ef0dd76965fb2c122493e7c1253f0
|
|
| BLAKE2b-256 |
0d0b2bd5d232ebe20d07f8dac3e25294b565f4abc78283fd598d2090872a48e0
|