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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for varframe-1.3.1.tar.gz
Algorithm Hash digest
SHA256 9d147f125d2eaa0ea7738a5afe334eb73f515eaaf4f29027cc0c2b39d83d02ee
MD5 21bcd7aa8c13c2a7b304636990d19a2a
BLAKE2b-256 3fd99439ae12adbae1349217dfd0be485303a48ad86df3b5d6e2f9d2aea04330

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: varframe-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 25.8 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.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d0905a5a15cca7a4271cdf323d7a1a8c3a0b3a3c4a222cc148e15f945483968f
MD5 5c1140e4938a045577a9616cac180ee0
BLAKE2b-256 fe9a18c2be49a16c505dbf72dde6b8e5ab2e3ebb8c0ff23dc770e98c369ecbf1

See more details on using hashes here.

Provenance

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