Skip to main content

Declarative DataFrame variable management with automatic DAG dependency resolution and ML model integration

Project description

VarFrame

Declarative DataFrame variable management with automatic DAG dependency resolution.

PyPI version License: MIT

VarFrame is a Python library designed to bring structure, reproducibility, and maintainability to your data science and machine learning pipelines. It transforms your data processing from a linear script into a robust, self-documenting graph of dependencies.

Documentation

Read the full documentation (or run mkdocs serve locally).

  • User Guide: Detailed concepts, lazy loading, and ML integration.
  • API Reference: Class and function specifications.

Why VarFrame?

Data pipelines often start as simple scripts but quickly grow into unmanageable "spaghetti code."

  • The Problem:

    • Implicit Dependencies: "Why did column X change? Oh, because I modified column Y 200 lines above."
    • Execution Order Fragility: "You have to run cell 4 before cell 2, but only if you skipped cell 3."
    • Copy-Paste Logic: Feature engineering logic gets duplicated across training and inference pipelines, leading to drift.
  • The VarFrame Solution:

    • Explicit Dependencies: Every variable declares exactly what it needs to be computed.
    • Automatic Resolution: VarFrame builds a Directed Acyclic Graph (DAG) and executes transformations in the mathematically correct order.
    • Single Source of Truth: Your variable classes are your pipeline. Use the exact same classes for training, evaluation, and production inference.

Traditional vs. VarFrame

Feature Traditional (Pandas Script) VarFrame
Logic Definition Imperative (df['new'] = df['old'] * 2) Declarative (Class New depends on Old)
Execution Order Manually managed (top-to-bottop) Automatic (DAG-based topological sort)
Reusability Low (Copy-paste code blocks) High (Import classes anywhere)
Lazy Loading Manual caching or re-computation Built-in (Compute only when accessed)
Documentation Comments scattered in code Self-documenting class structure

Key Features

  • Declarative Syntax: Define variables as Python classes.
  • Automatic Dependency Resolution: Never worry about execution order again.
  • Lazy Loading: Defer expensive computations until the data is actually needed.
  • ML Integration: Built-in BaseModel and ModelVariable to treat model predictions just like any other column.
  • Metadata Preserved: Export to Parquet with variable metadata intact.

Installation

VarFrame is available on PyPI:

pip install varframe

Quick Start

Here is a simple example showing how VarFrame automatically resolves dependencies.

import pandas as pd
from varframe import VarFrame, BaseVariable, DerivedVariable

# 1. Define your variables as classes
class Radius(BaseVariable):
    raw_column = "radius" # Maps to input DataFrame column
    dtype = "float"

class Area(DerivedVariable):
    # Dependencies are specific pointers to other variable classes
    dependencies = [Radius]

    @classmethod
    def calculate(cls, df):
        import math
        # Access column by variable name
        return math.pi * (df[Radius.name] ** 2)

# 2. Initialize with data
data = pd.DataFrame({"radius": [1, 2, 5]})
vf = VarFrame(data)

# 3. Resolve dependencies
# You ask for 'Area', VarFrame knows it needs 'Radius'
vf.resolve(Area)

print(vf.df)
#    radius       area
# 0     1.0   3.141593
# 1     2.0  12.566371
# 2     5.0  78.539816

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

varframe-1.4.1.tar.gz (30.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

varframe-1.4.1-py3-none-any.whl (29.1 kB view details)

Uploaded Python 3

File details

Details for the file varframe-1.4.1.tar.gz.

File metadata

  • Download URL: varframe-1.4.1.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for varframe-1.4.1.tar.gz
Algorithm Hash digest
SHA256 de50968f8259f1dd6f7bb60a8d121bfa915352d5ee0a1f77e759fad8cf350338
MD5 bd3abe1aeeb97d6233fb2c8bf82c34f3
BLAKE2b-256 1dd3e650aa76782bcffbc5e6be926b49f2f249ff6e1219df10939a50f48f4ada

See more details on using hashes here.

Provenance

The following attestation bundles were made for varframe-1.4.1.tar.gz:

Publisher: publish.yml on Santi-49/varframe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file varframe-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: varframe-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 29.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for varframe-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e4521c5a818cbe7829f20f5a81c5b87e7174644e84a919bae845847060f90abb
MD5 3685c1f923afe218788144bd06413d28
BLAKE2b-256 bb32ce7bd099312b00d58543c6249cd0e2080fefc67e2f3f86a9f099f6cb9862

See more details on using hashes here.

Provenance

The following attestation bundles were made for varframe-1.4.1-py3-none-any.whl:

Publisher: publish.yml on Santi-49/varframe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page