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.0.tar.gz (27.3 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.0-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: varframe-1.4.0.tar.gz
  • Upload date:
  • Size: 27.3 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.0.tar.gz
Algorithm Hash digest
SHA256 b6d2e80e6a70dedbadbd5cc2523ab41ade2eff2cc677c864e5ce5cc7c611c399
MD5 707450670c659185f1348374a63bb5f3
BLAKE2b-256 b7f45ad8f2429b55c8efc29228863a45ea63d1ebc4477f6e2721994b69d884ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for varframe-1.4.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: varframe-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 27.4 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e0457685a82ddeb46097ab153c4e43b5eb2404827696de5a3378164f8312afb
MD5 b1b449ec525e9e8b2245c9e9e904c48b
BLAKE2b-256 2bdbc5d1034e85b779eeb0c089d0ab804215d66af4d7e9ae40963c1df79b43e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for varframe-1.4.0-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