Skip to main content

DataFrameIt

PyPI version Python 3.10+ License: MIT

English · Português · Español

Enrich DataFrames with LLMs, simply and in a structured way.

DataFrameIt processes text in DataFrames using Large Language Models (LLMs) and extracts structured information defined by Pydantic models.

Full Documentation | LLM Reference

Installation

pip install dataframeit[google]  # Google Gemini (recommended)
pip install dataframeit[openai]  # OpenAI
pip install dataframeit[anthropic]  # Anthropic Claude
pip install dataframeit[codex]  # Official Codex SDK (experimental)

Set up provider authentication:

export GOOGLE_API_KEY="your-key"  # or OPENAI_API_KEY, ANTHROPIC_API_KEY

The experimental codex provider is optional, is not part of the all extra, uses the bundled runtime and requires local file-based authentication. See the installation docs to set up the extra and the credentials.

Quick Example

from pydantic import BaseModel
from typing import Literal
import pandas as pd
from dataframeit import dataframeit

# 1. Define what to extract
class Sentiment(BaseModel):
    sentiment: Literal['positive', 'negative', 'neutral']
    confidence: Literal['high', 'medium', 'low']

# 2. Your data
df = pd.DataFrame({
    'text': [
        'Excellent product! Exceeded my expectations.',
        'Terrible service, never buying again.',
        'Delivery was fine, product is average.'
    ]
})

# 3. Process!
result = dataframeit(df, Sentiment, "Analyze the sentiment of the text.")
print(result)

Output:

text sentiment confidence
Excellent product! ... positive high
Terrible service... negative high
Delivery was fine... neutral medium

Field and class names are arbitrary — the examples in the example/ notebooks use Portuguese ones.

Features

  • Multiple providers: Google Gemini, OpenAI, Anthropic, Cohere and Mistral via LangChain, plus Claude Code and Codex through their SDKs
  • Multiple input types: DataFrame, Series, list, dict
  • Structured output: Automatic validation with Pydantic
  • Resilience: Automatic retry with exponential backoff
  • Performance: Parallel processing, configurable rate limiting
  • Web search: Tavily integration to enrich data
  • Tracking: Token monitoring and throughput metrics
  • Per-field configuration: Custom prompts and search parameters per field (v0.5.2+)

Per-Field Configuration (New in v0.5.2)

Set field-specific prompts and search parameters using json_schema_extra:

from pydantic import BaseModel, Field

class DrugInfo(BaseModel):
    # Field with the default prompt
    active_ingredient: str = Field(description="Active ingredient of the drug")

    # Field with a custom prompt (replaces the base prompt)
    rare_disease: str = Field(
        description="Rare disease classification",
        json_schema_extra={
            "prompt": "Search Orphanet (orpha.net). Analyze: {text}"
        }
    )

    # Field with an additional prompt (appended to the base prompt)
    conitec_assessment: str = Field(
        description="CONITEC assessment",
        json_schema_extra={
            "prompt_append": "Search ONLY the CONITEC website (gov.br/conitec)."
        }
    )

    # Field with custom search parameters
    clinical_trials: str = Field(
        description="Relevant clinical trials",
        json_schema_extra={
            "prompt_append": "Search for recent clinical trials.",
            "search_depth": "advanced",
            "max_results": 10
        }
    )

# Requires search_per_field=True
result = dataframeit(
    df,
    DrugInfo,
    "Analyze the drug: {text}",
    use_search=True,
    search_per_field=True,
)

Available options in json_schema_extra:

Option Description
prompt or prompt_replace Fully replaces the base prompt
prompt_append Appends text to the base prompt
search_depth "basic" or "advanced" (per-field override)
max_results Number of search results (1-20)

Documentation

Examples

See the example/ folder for Jupyter notebooks with complete use cases.

License

MIT

Release files for dataframeit 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dataframeit 0.8.0
File Size Uploaded
dataframeit-0.8.0.tar.gz 50.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dataframeit 0.8.0
File Interpreter ABI Platform
dataframeit-0.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 107.7 kB

Release files / dataframeit-0.8.0.tar.gz

Download URL dataframeit-0.8.0.tar.gz
Size 50.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8d265533574bf656057de111ee0437f9de44317a05dcd4f71ce1d37983c0fe96
BLAKE2b-256 checksum
How to use checksums
254d98cba935ca14eeb68ec408ddd685210174596ea56fa6b70000107d6611c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / dataframeit-0.8.0-py3-none-any.whl

Download URL dataframeit-0.8.0-py3-none-any.whl
Size 57.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
11892f137acc5dc2fa6bfacedd971936440d86de047c8594dee41909cc192b60
BLAKE2b-256 checksum
How to use checksums
9dcc8244ddaaaaada95bda33282602b829470f365d45f4a754265742403c6045
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.11 {"installer":{"name":"uv","version":"0.12.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.10.0

2 release files

0.9.0

2 release files

0.8.1

2 release files

This release

0.8.0 This release

2 release files

0.6.0

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page