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[openai]  # OpenAI (default provider)
pip install dataframeit[google]  # Google Gemini
pip install dataframeit[anthropic]  # Anthropic Claude
pip install dataframeit[codex]  # Official Codex SDK (experimental)
pip install dataframeit[claude-code]  # Claude Code via the Claude Agent SDK

Set up provider authentication:

export OPENAI_API_KEY="your-key"  # or GOOGLE_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: {texto}"
        }
    )

    # 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: {texto}",
    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.10.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.10.0
File Size Uploaded
dataframeit-0.10.0.tar.gz 66.1 kB Details

Built distribution (wheel)

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

Total release size: 138.8 kB

Release files / dataframeit-0.10.0.tar.gz

Download URL dataframeit-0.10.0.tar.gz
Size 66.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c04fee8e1d88bcb6cc71d45d960e686c72979859d2e03cd1b1a17b95050584db
BLAKE2b-256 checksum
How to use checksums
89eed3a7a6047a3b5d8d981c101af0231523878f54cd06b41e6e1882787b1238
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.10.0-py3-none-any.whl

Download URL dataframeit-0.10.0-py3-none-any.whl
Size 72.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
51d7bd0aa95287d1f9b3c7f3848172726dbda5d2907cc2c4a1caa621a97fcaf6
BLAKE2b-256 checksum
How to use checksums
d9c3c765ea753a0b86f91a53760f366390a45589ffedd24ba059e92d06e14750
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

This release

0.10.0 This release

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

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