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.
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
Xchange? Oh, because I modified columnY200 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.
- Implicit Dependencies: "Why did column
-
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
BaseModelandModelVariableto 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de50968f8259f1dd6f7bb60a8d121bfa915352d5ee0a1f77e759fad8cf350338
|
|
| MD5 |
bd3abe1aeeb97d6233fb2c8bf82c34f3
|
|
| BLAKE2b-256 |
1dd3e650aa76782bcffbc5e6be926b49f2f249ff6e1219df10939a50f48f4ada
|
Provenance
The following attestation bundles were made for varframe-1.4.1.tar.gz:
Publisher:
publish.yml on Santi-49/varframe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
varframe-1.4.1.tar.gz -
Subject digest:
de50968f8259f1dd6f7bb60a8d121bfa915352d5ee0a1f77e759fad8cf350338 - Sigstore transparency entry: 813715777
- Sigstore integration time:
-
Permalink:
Santi-49/varframe@0a725c67218613f7c5f0f2163bb8a5893559beac -
Branch / Tag:
refs/tags/v1.4.1 - Owner: https://github.com/Santi-49
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0a725c67218613f7c5f0f2163bb8a5893559beac -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4521c5a818cbe7829f20f5a81c5b87e7174644e84a919bae845847060f90abb
|
|
| MD5 |
3685c1f923afe218788144bd06413d28
|
|
| BLAKE2b-256 |
bb32ce7bd099312b00d58543c6249cd0e2080fefc67e2f3f86a9f099f6cb9862
|
Provenance
The following attestation bundles were made for varframe-1.4.1-py3-none-any.whl:
Publisher:
publish.yml on Santi-49/varframe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
varframe-1.4.1-py3-none-any.whl -
Subject digest:
e4521c5a818cbe7829f20f5a81c5b87e7174644e84a919bae845847060f90abb - Sigstore transparency entry: 813715778
- Sigstore integration time:
-
Permalink:
Santi-49/varframe@0a725c67218613f7c5f0f2163bb8a5893559beac -
Branch / Tag:
refs/tags/v1.4.1 - Owner: https://github.com/Santi-49
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0a725c67218613f7c5f0f2163bb8a5893559beac -
Trigger Event:
release
-
Statement type: