A framework for declarative, functional dataset definitions.
Project description
Labrea
A framework for declarative, functional dataset definitions.
Installation
Labrea is available for install via pip.
pip install labrea
Alternatively, you can install the latest development version from GitHub.
pip install git+https://github.com/8451/labrea@develop
Usage
See our usage guide here.
Labrea exposes a dataset decorator that allows you to define datasets and their dependencies in a declarative manner.
Dependencies can either be other datasets or Options, which are values that can be passed in at runtime via a
dictionary.
from labrea import dataset, Option
import pandas as pd
@dataset
def stores(path: str = Option('PATHS.STORES')) -> pd.DataFrame:
return pd.read_csv(path)
@dataset
def transactions(path: str = Option('PATHS.SALES')) -> pd.DataFrame:
return pd.read_csv(path)
@dataset
def sales_by_region(
stores_: pd.DataFrame = stores,
transactions_: pd.DataFrame = transactions
) -> pd.DataFrame:
"""Merge stores to transactions, sum sales by region"""
return pd.merge(transactions_, stores_, on='store_id').groupby('region')['sales'].sum().reset_index()
options = {
'PATHS': {
'STORES': 'path/to/stores.csv',
'SALES': 'path/to/sales.csv'
}
}
stores(options)
## +-----------------+-----------+
## | store_id | region |
## |-----------------+-----------|
## | 1 | North |
## | 2 | North |
## | 3 | South |
## | 4 | South |
## +-----------------+-----------+
transactions(options)
## +-----------------+-----------------+-----------------+
## | store_id | sales | transaction_id |
## |-----------------+-----------------+-----------------|
## | 1 | 100 | 1 |
## | 2 | 200 | 2 |
## | 3 | 300 | 3 |
## | 4 | 400 | 4 |
## +-----------------+-----------------+-----------------+
sales_by_region(options)
## +-----------------+-----------------+
## | region | sales |
## |-----------------+-----------------|
## | North | 300 |
## | South | 700 |
## +-----------------+-----------------+
Contributing
If you would like to contribute to labrea, please read the Contributing Guide.
Changelog
A summary of recent updates to labrea can be found in the Changelog.
Maintainers
| Maintainer | |
|---|---|
| Austin Warner | austin.warner@8451.com |
| Michael Stoepel | michael.stoepel@8451.com |
Links
- Report a bug or request a feature: https://github.com/8451/labrea/issues/new/choose
- Documentation: https://8451.github.io/labrea
Project details
Release history Release notifications | RSS feed
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 labrea-2.1.2.tar.gz.
File metadata
- Download URL: labrea-2.1.2.tar.gz
- Upload date:
- Size: 259.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4d74c478828004fc1ce2e2180dd889087e783afb3e75b0bed0b549bea355bba
|
|
| MD5 |
40ef3708d7f9112231ff19009e8b11b2
|
|
| BLAKE2b-256 |
16b8dc2234c7fe41bfd1cbd48bc135560e0a3120c50b4289979cd98d514c9e8d
|
Provenance
The following attestation bundles were made for labrea-2.1.2.tar.gz:
Publisher:
build-and-deploy.yml on 8451/labrea
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
labrea-2.1.2.tar.gz -
Subject digest:
e4d74c478828004fc1ce2e2180dd889087e783afb3e75b0bed0b549bea355bba - Sigstore transparency entry: 207040059
- Sigstore integration time:
-
Permalink:
8451/labrea@39eb09fb0908dec6e72f2fd13c1bff62a6b21096 -
Branch / Tag:
refs/tags/v2.1.2 - Owner: https://github.com/8451
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-and-deploy.yml@39eb09fb0908dec6e72f2fd13c1bff62a6b21096 -
Trigger Event:
release
-
Statement type:
File details
Details for the file labrea-2.1.2-py3-none-any.whl.
File metadata
- Download URL: labrea-2.1.2-py3-none-any.whl
- Upload date:
- Size: 55.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35adb0d89f0b93a1285c76eeb5f8f85ba4d9dcdb047b8bdc472e8152d79360a7
|
|
| MD5 |
d21b20f9c219aaab309d5a2879b592dd
|
|
| BLAKE2b-256 |
a6a43025f71f409c79db1244d310f042b8efb6aeb2b8e85df68a71768e85339b
|
Provenance
The following attestation bundles were made for labrea-2.1.2-py3-none-any.whl:
Publisher:
build-and-deploy.yml on 8451/labrea
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
labrea-2.1.2-py3-none-any.whl -
Subject digest:
35adb0d89f0b93a1285c76eeb5f8f85ba4d9dcdb047b8bdc472e8152d79360a7 - Sigstore transparency entry: 207040060
- Sigstore integration time:
-
Permalink:
8451/labrea@39eb09fb0908dec6e72f2fd13c1bff62a6b21096 -
Branch / Tag:
refs/tags/v2.1.2 - Owner: https://github.com/8451
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-and-deploy.yml@39eb09fb0908dec6e72f2fd13c1bff62a6b21096 -
Trigger Event:
release
-
Statement type: