Skip to main content

DataFrameIt

PyPI version Python 3.11+ License: MIT Tests

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[groq]         # Groq
pip install dataframeit[codex]        # Official Codex SDK (experimental)
pip install dataframeit[claude-code]  # Claude Code via the Claude Agent SDK
pip install dataframeit[all]          # the providers above except Codex, plus web search, Polars and Excel

Optional extras: search (Tavily), search-exa (Exa), search-all, polars, excel.

Set up provider authentication:

export OPENAI_API_KEY="your-key"  # or GOOGLE_API_KEY, ANTHROPIC_API_KEY, GROQ_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

With track_tokens=True, the default, the output also has the token usage columns _input_tokens, _cached_input_tokens, _output_tokens and _reasoning_tokens, left out of the table above.

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

Features

  • Multiple providers: OpenAI, Google Gemini, Anthropic and Groq with their own extras, any other LangChain provider (Cohere, Mistral, Vertex AI, Bedrock, Azure) by installing its package, plus Claude Code and Codex through their official SDKs
  • Multiple input types: pandas or Polars DataFrame and Series, list, dict
  • Structured output: Pydantic validation; with the LangChain providers, a rejected answer goes back to the model with the error
  • Resilience: Automatic retry with exponential backoff, and periodic checkpoints (batch_size + checkpoint_path) to resume long runs
  • Performance: Continuous parallel queue that halves the rows in flight on rate limits, configurable rate limiting, and a per-row callback (on_row_done) that runs on the worker thread
  • Web search: Tavily or Exa, per field or per group of fields, with conditional fields (condition, depends_on)
  • Tracking: Token usage, search credits and throughput metrics

Per-Field Configuration

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,
)

The full list of per-field options (including max_search_calls, condition and depends_on) is in the web search guide.

Documentation

Examples

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

Contributing

See CONTRIBUTING.md.

License

MIT

Metadata

Release files for dataframeit 0.11.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.11.0
File Size Uploaded Provenance Actions
dataframeit-0.11.0.tar.gz 113.0 kB Without provenance Details for dataframeit-0.11.0.tar.gz

Built distribution (wheel)

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

Total release size: 232.3 kB

Release files / dataframeit-0.11.0.tar.gz

Download URL dataframeit-0.11.0.tar.gz
Size 113.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b3d71da6123b7a84fb95886afb460acafc6372eaeca2432932705fc0c0c0122e
BLAKE2b-256 checksum
How to use checksums
a23a150be9f8ba7b59622b1e4cd9de5c4790348feea2af38970e98a6595bee86
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.11.0-py3-none-any.whl

Download URL dataframeit-0.11.0-py3-none-any.whl
Size 119.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
26d2b8e4a781a16bdf19157bf065f18938583d0441bfef7752bf198356e1e7ea
BLAKE2b-256 checksum
How to use checksums
2e70063949679eb2522f23728ba624f27c98fe8bb44bff55e85258817f4daf93
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}

Security for dataframeit 0.11.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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